Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

* files distributed by yacy are utf-8, files from repository use the system default charset * fixes http://forum.yacy-websuche.de/viewtopic.php?f=6&t=1564#p11092 and http://forum.yacy-websuche.de/viewtopic.php?f=6&t=1550

f1orid49ffcd81860
diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.java
index 03716ddc4..38f8cb078 100644
--- a/source/de/anomic/http/httpdFileHandler.java
+++ b/source/de/anomic/http/httpdFileHandler.java
@@ -696,17 +696,24 @@ public final class httpdFileHandler {
fis = new BufferedInputStream(new FileInputStream(targetFile));
}
- // detect charset of html-files
- if(path.endsWith("html") || path.endsWith("htm")) {
- // save position
- fis.mark(1000);
- // scrape document to look up charset
- final htmlFilterInputStream htmlFilter = new htmlFilterInputStream(fis,"UTF-8",new yacyURL("http://localhost", null),null,false);
- final String charset = plasmaParser.patchCharsetEncoding(htmlFilter.detectCharset());
- // reset position
- fis.reset();
- if(charset != null)
- mimeType = mimeType + "; charset="+charset;
+ if(mimeType.startsWith("text")) {
+ // every text-file distributed by yacy is UTF-8
+ if(!path.startsWith("/repository")) {
+ mimeType = mimeType + "; charset=UTF-8";
+ } else {
+ // detect charset of html-files
+ if((path.endsWith("html") || path.endsWith("htm"))) {
+ // save position
+ fis.mark(1000);
+ // scrape document to look up charset
+ final htmlFilterInputStream htmlFilter = new htmlFilterInputStream(fis,"UTF-8",new yacyURL("http://localhost", null),null,false);
+ final String charset = plasmaParser.patchCharsetEncoding(htmlFilter.detectCharset());
+ if(charset != null)
+ mimeType = mimeType + "; charset="+charset;
+ // reset position
+ fis.reset();
+ }
+ }
}
// write the array to the client