Skip to content

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

small corrections to image loading methods in result presentation especially loading of favicons in search results. This is a fix that affects only searches in intranet/repository configurations.

orbiterf1b712c29a94
diff --git a/htroot/ViewImage.java b/htroot/ViewImage.java
index 3fc7f3e0c..82efbfc1f 100644
--- a/htroot/ViewImage.java
+++ b/htroot/ViewImage.java
@@ -43,6 +43,13 @@ public class ViewImage {
private static HashMap<String, Image> iconcache = new HashMap<String, Image>();
private static String defaulticon = "htroot/env/grafics/dfltfvcn.ico";
+ private static byte[] defaulticonb;
+ static {
+ try {
+ defaulticonb = FileUtils.read(new File(defaulticon));
+ } catch (final IOException e) {
+ }
+ }
public static Image respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
@@ -68,9 +75,6 @@ public class ViewImage {
urlString = (url == null) ? null : url.toNormalform(true, true);
}
- if (url == null) return null;
- System.out.println("loading image from " + url.toString());
-
int width = post.getInt("width", 0);
int height = post.getInt("height", 0);
int maxwidth = post.getInt("maxwidth", 0);
@@ -81,7 +85,7 @@ public class ViewImage {
Image scaled = iconcache.get(urlString);
if (scaled == null) {
Object[] resource = null;
- try {
+ if (url != null) try {
resource = plasmaSnippetCache.getResource(url, true, timeout, false, true);
} catch (IOException e) {
Log.logWarning("ViewImage", "cannot load: " + e.getMessage());
@@ -90,10 +94,12 @@ public class ViewImage {
if (resource == null) {
if (urlString.endsWith(".ico")) {
// load default favicon dfltfvcn.ico
- try {
+ if (defaulticonb == null) try {
imgb = FileUtils.read(new File(sb.getRootPath(), defaulticon));
} catch (final IOException e) {
return null;
+ } else {
+ imgb = defaulticonb;
}
} else {
return null;
diff --git a/htroot/yacysearchitem.html b/htroot/yacysearchitem.html
index b51776512..686dcb237 100644
--- a/htroot/yacysearchitem.html
+++ b/htroot/yacysearchitem.html
@@ -1,7 +1,7 @@
#(content)#::
<div class="searchresults">
<h4 class="linktitle">
- <img src="ViewImage.png?width=16&amp;height=16&amp;code=#[faviconCode]#" id="f#[urlhash]#" class="favicon" style="width:16px; height:16px;" alt="favicon" />
+ <img src="ViewImage.png?width=16&amp;height=16&amp;code=#[faviconCode]#" id="f#[urlhash]#" class="favicon" style="width:16px; height:16px;" alt="" />
<a href="#[link]#">#[title]#</a></h4>
#(authorized)#::
<div class="urlactions">
diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java
index 1722b7b18..6d850f6fb 100644
--- a/htroot/yacysearchitem.java
+++ b/htroot/yacysearchitem.java
@@ -98,8 +98,8 @@ public class yacysearchitem {
final int port=result.url().getPort();
- yacyURL faviconURL;
- try {
+ yacyURL faviconURL = null;
+ if (!result.url().isLocal()) try {
faviconURL = new yacyURL(result.url().getProtocol() + "://" + result.url().getHost() + ((port != -1) ? (":" + String.valueOf(port)) : "") + "/favicon.ico", null);
} catch (final MalformedURLException e1) {
faviconURL = null;
diff --git a/httpd.mime b/httpd.mime
index 418397409..e36d09c76 100644
--- a/httpd.mime
+++ b/httpd.mime
@@ -10,6 +10,7 @@ au = audio/basic
avi = video/x-msvideo
bat = text/plain
bin = application/octet-stream
+bmp = image/bmp
bz2 = application/x-bzip2
class = application/octet-stream
c = text/plain
@@ -29,6 +30,7 @@ gz = application/gzip
hqx = application/mac-binhex40
htm = text/html
html = text/html
+ico = image/bmp
jar = application/java-archive
java = text/plain
jpe = image/jpeg
diff --git a/source/de/anomic/data/URLLicense.java b/source/de/anomic/data/URLLicense.java
index f28c620eb..54bdc60e3 100644
--- a/source/de/anomic/data/URLLicense.java
+++ b/source/de/anomic/data/URLLicense.java
@@ -56,6 +56,7 @@ public class URLLicense {
public String aquireLicense(final yacyURL url) {
// generate license key
String license = "";
+ if (url == null) return license;
while (license.length() < keylen) license += Integer.toHexString(random.nextInt());
license = license.substring(0, keylen);
// store reference to url with license key