Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) Bugfix. htmlFilterInputStream document analysis did not work properly for documents smaller than the default InputStream Buffer size.
thelicf6acff2c204
diff --git a/source/de/anomic/htmlFilter/htmlFilterInputStream.java b/source/de/anomic/htmlFilter/htmlFilterInputStream.javaindex 12ddd2ed6..d5d34e41f 100644--- a/source/de/anomic/htmlFilter/htmlFilterInputStream.java+++ b/source/de/anomic/htmlFilter/htmlFilterInputStream.java@@ -15,12 +15,15 @@ import de.anomic.net.URL;public class htmlFilterInputStream extends InputStream implements htmlFilterEventListener {+ private static final int MODE_PRESCAN = 0;+ private static final int MODE_PRESCAN_FINISHED = 1;+ private int mode = 1;+private long preBufferSize = 143336;private long preRead = 0;private BufferedInputStream bufferedIn;private String detectedCharset;- private int mode = 0;private boolean charsetChanged = false;private boolean endOfHead = false;@@ -52,9 +55,15 @@ public class htmlFilterInputStream extends InputStream implements htmlFilterEvenif (tagopts.containsKey("http-equiv")) {String value = tagopts.getProperty("http-equiv");if (value.equalsIgnoreCase("Content-Type")) {- String contentType = tagopts.getProperty("content");+ String contentType = tagopts.getProperty("content","");this.detectedCharset = httpHeader.extractCharsetFromMimetyeHeader(contentType);- this.charsetChanged = true;+ if (this.detectedCharset != null && this.detectedCharset.length() > 0) {+ this.charsetChanged = true;+ } else if (tagopts.containsKey("charset")) {+ // sometimes the charset property is configured as extra attribut. try it ...+ this.detectedCharset = tagopts.getProperty("charset");+ this.charsetChanged = true;+ }}}}@@ -69,6 +78,8 @@ public class htmlFilterInputStream extends InputStream implements htmlFilterEven}public String detectCharset() throws IOException {+ this.mode = MODE_PRESCAN;+// loop until we have detected the header element or the charset dataint c;while ((c = this.reader.read())!= -1) {@@ -78,13 +89,17 @@ public class htmlFilterInputStream extends InputStream implements htmlFilterEven// free writerthis.writer = null;// don't close writer here, otherwise it will shutdown our source stream++ // reset the buffer if not already done+ if (this.mode != MODE_PRESCAN_FINISHED) this.bufferedIn.reset();+ // return scanning resultreturn (this.charsetChanged) ? this.detectedCharset : null;}public int read() throws IOException {// mode 0 is called from within the detectCharset function- if (this.mode == 0) {+ if (this.mode == MODE_PRESCAN) {if (this.endOfHead || this.charsetChanged || this.preRead >= this.preBufferSize) {this.mode++;this.bufferedIn.reset();diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex dc557ff2b..a8003fad0 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -1706,7 +1706,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serlog.logInfo("*Indexed " + words + " words in URL " + entry.url() +" [" + entry.urlHash() + "]" +"\n\tDescription: " + docDescription +- "\n\tMimeType: " + document.getMimeType() + " | " ++ "\n\tMimeType: " + document.getMimeType() + " | Charset: " + document.getCharset() + " | " +"Size: " + document.text.length + " bytes | " +"Anchors: " + ((document.anchors==null)?0:document.anchors.size()) +"\n\tStackingTime: " + (stackEndTime-stackStartTime) + " ms | " +