Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1115 Option to disable fixing of URL embedded parameters in DomContentUtils

Markus Jelsmaae2c38d56c63
diff --git a/conf/nutch-default.xml b/conf/nutch-default.xml
index 3a7f46a29..cf451f4e6 100644
--- a/conf/nutch-default.xml
+++ b/conf/nutch-default.xml
@@ -921,7 +921,6 @@
"all" doesn't show either content or summaries.</description>
</property>
-
<property>
<name>parser.html.impl</name>
<value>neko</value>
@@ -949,6 +948,13 @@
for most people would be "img,script,link".</description>
</property>
+<property>
+ <name>parser.fix.embeddedparams</name>
+ <value>true</value>
+ <description>Whether to fix URL embedded params using semi-colons.
+ See NUTCH-436 and NUTCH-1115</description>
+</property>
+
<property>
<name>htmlparsefilter.order</name>
<value></value>
diff --git a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMContentUtils.java b/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMContentUtils.java
index 7f25efdc8..6c7242684 100644
--- a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMContentUtils.java
+++ b/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMContentUtils.java
@@ -39,6 +39,8 @@ import org.w3c.dom.*;
*/
public class DOMContentUtils {
+ private boolean fixEmbeddedParams;
+
public static class LinkParams {
public String elName;
public String attrName;
@@ -87,6 +89,9 @@ public class DOMContentUtils {
if ( ! forceTags.contains(ignoreTags[i]) )
linkParams.remove(ignoreTags[i]);
}
+
+ // https://issues.apache.org/jira/browse/NUTCH-1115
+ fixEmbeddedParams = conf.getBoolean("parser.fix.embeddedparams", true);
}
/**
@@ -321,7 +326,7 @@ public class DOMContentUtils {
// the target contains params information or the base doesn't then no
// conversion necessary, return regular URL
- if (target.indexOf(';') >= 0 || base.toString().indexOf(';') == -1) {
+ if (!fixEmbeddedParams || target.indexOf(';') >= 0 || base.toString().indexOf(';') == -1) {
return new URL(base, target);
}
diff --git a/src/plugin/parse-tika/src/java/org/apache/nutch/parse/tika/DOMContentUtils.java b/src/plugin/parse-tika/src/java/org/apache/nutch/parse/tika/DOMContentUtils.java
index 91771048d..9d84db553 100644
--- a/src/plugin/parse-tika/src/java/org/apache/nutch/parse/tika/DOMContentUtils.java
+++ b/src/plugin/parse-tika/src/java/org/apache/nutch/parse/tika/DOMContentUtils.java
@@ -39,6 +39,8 @@ import org.w3c.dom.NodeList;
*/
class DOMContentUtils {
+ private boolean fixEmbeddedParams;
+
private static class LinkParams {
private String elName;
private String attrName;
@@ -87,6 +89,9 @@ class DOMContentUtils {
if ( ! forceTags.contains(ignoreTags[i]) )
linkParams.remove(ignoreTags[i]);
}
+
+ // https://issues.apache.org/jira/browse/NUTCH-1115
+ fixEmbeddedParams = conf.getBoolean("parser.fix.embeddedparams", true);
}
/**
@@ -318,10 +323,10 @@ class DOMContentUtils {
*/
private URL fixEmbeddedParams(URL base, String target)
throws MalformedURLException{
-
+
// the target contains params information or the base doesn't then no
// conversion necessary, return regular URL
- if (target.indexOf(';') >= 0 || base.toString().indexOf(';') == -1) {
+ if (!fixEmbeddedParams || target.indexOf(';') >= 0 || base.toString().indexOf(';') == -1) {
return new URL(base, target);
}
@@ -340,7 +345,7 @@ class DOMContentUtils {
else {
target += params;
}
-
+
return new URL(base, target);
}