Permalink
Browse files

Display result favicons only for http or https resources.

Favicon display only makes sense for http(s) websites, being public or
intranet. So I modified the favicon conditional display to verify the
result URL protocol rather than if we are in intranet mode.

Also prevented rendering an img HTML tag with empty src on other results
protocols such as ftp or file.

Fixing this thanks to priest2 report
(http://forum.yacy-websuche.de/viewtopic.php?f=23&t=5923).
  • Loading branch information...
luccioman committed Jan 6, 2017
1 parent 4c9be29 commit 52d05d14c6c834b46ac6bf8d3729b04ab4f12eaa
Showing with 11 additions and 4 deletions.
  1. +3 −1 htroot/yacysearchitem.html
  2. +7 −2 htroot/yacysearchitem.java
  3. +1 −1 htroot/yacysearchitem.json
@@ -1,7 +1,9 @@
#(content)#::
<div class="searchresults">
<h4 class="linktitle">
<img width="16" height="16" src="#[faviconUrl]#" id="f#[urlhash]#" class="favicon" style="width:16px; height:16px;" alt="" />
#(favicon)#::
<img width="16" height="16" src="#[faviconUrl]#" id="f#[urlhash]#" class="favicon" style="width:16px; height:16px;" alt="" />
#(/favicon)#
<a href="#[link]#" target="#[target]#">#[title]#</a></h4>
<div class="urlactions">
#(heuristic)#::
@@ -184,10 +184,15 @@ public static serverObjects respond(final RequestHeader header, final serverObje
String resultFileName = resultURL.getFileName();
prop.putHTML("content_target", target);
DigestURL faviconURL = null;
if ((fileType == FileType.HTML || fileType == FileType.JSON) && !sb.isIntranetMode()) {
if ((fileType == FileType.HTML || fileType == FileType.JSON) && (resultURL.isHTTP() || resultURL.isHTTPS())) {
faviconURL = getFaviconURL(result, new Dimension(16, 16));
}
prop.putHTML("content_faviconUrl", processFaviconURL(ImageViewer.hasFullViewingRights(header, sb), faviconURL));
if(faviconURL == null) {
prop.put("content_favicon", 0);
} else {
prop.put("content_favicon", 1);
}
prop.putHTML("content_favicon_faviconUrl", processFaviconURL(ImageViewer.hasFullViewingRights(header, sb), faviconURL));
prop.put("content_urlhash", urlhash);
prop.put("content_ranking", Float.toString(result.score()));
Date[] events = result.events();
@@ -9,7 +9,7 @@
"size": "#[size]#",
"sizename": "#[sizename]#",
"guid": "#[urlhash]#",
"faviconUrl": "#[faviconUrl]#",
#(favicon)#::"faviconUrl": "#[faviconUrl]#",#(/favicon)#
"host": "#[host]#",
"path": "#[path]#",
"file": "#[file]#",

0 comments on commit 52d05d1

Please sign in to comment.