Skip to content

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

*) Bugfix for not human readable content of PDFs while viewing the URL Content via GUI - This Bug also affects the snippet generation on non html/text documents See: http://www.yacy-forum.de/viewtopic.php?t=1472

thelibbb936b9ea48
diff --git a/libx/jmimemagic-0.0.4a.jar b/libx/jmimemagic-0.0.4a.jar
index 7e8b9d00a..a95d8c566 100644
Binary files a/libx/jmimemagic-0.0.4a.jar and b/libx/jmimemagic-0.0.4a.jar differ
diff --git a/source/de/anomic/plasma/plasmaSnippetCache.java b/source/de/anomic/plasma/plasmaSnippetCache.java
index cb1be2de0..c7bc9ef3f 100644
--- a/source/de/anomic/plasma/plasmaSnippetCache.java
+++ b/source/de/anomic/plasma/plasmaSnippetCache.java
@@ -321,21 +321,34 @@ public class plasmaSnippetCache {
if (resource == null) return null;
httpHeader header = null;
try {
- header = cacheManager.getCachedResponse(plasmaURL.urlHash(url));
+ header = this.cacheManager.getCachedResponse(plasmaURL.urlHash(url));
} catch (IOException e) {}
if (header == null) {
- String filename = cacheManager.getCachePath(url).getName();
+ String filename = this.cacheManager.getCachePath(url).getName();
int p = filename.lastIndexOf('.');
- if ((p < 0) ||
- ((p >= 0) && (plasmaParser.supportedFileExtContains(filename.substring(p + 1))))) {
- return parser.parseSource(url, "text/html", resource);
+ if (
+ (p < 0) ||
+ ((p >= 0) && (plasmaParser.supportedFileExtContains(filename.substring(p + 1))))
+ ) {
+ String supposedMime = "text/html";
+
+ // if the mimeType Parser is installed we can set the mimeType to null to force
+ // a mimetype detection
+ if (plasmaParser.supportedMimeTypesContains("application/octet-stream")) {
+ supposedMime = null;
+ } else if (p != -1){
+ // otherwise we try to determine the mimeType per file Extension
+ supposedMime = plasmaParser.getMimeTypeByFileExt(filename.substring(p + 1));
+ }
+
+ return this.parser.parseSource(url, supposedMime, resource);
} else {
return null;
}
} else {
if (plasmaParser.supportedMimeTypesContains(header.mime())) {
- return parser.parseSource(url, header.mime(), resource);
+ return this.parser.parseSource(url, header.mime(), resource);
} else {
return null;
}