Skip to content

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

Absolute URLs in yacysearch.* : ensure no downgrade from https to http

luccioman6a0b218ae55c
diff --git a/htroot/yacysearch.atom b/htroot/yacysearch.atom
index 7270ab332..4513f8ce2 100644
--- a/htroot/yacysearch.atom
+++ b/htroot/yacysearch.atom
@@ -12,7 +12,7 @@
<opensearch:startIndex>#[num-results_offset]#</opensearch:startIndex>
<opensearch:itemsPerPage>#[num-results_itemsPerPage]#</opensearch:itemsPerPage>
<link rel="self" href="#[searchBaseURL]#?query=#[rss_queryenc]#&amp;resource=#[resource]#&amp;contentdom=#[contentdom]#&amp;verify=#[search.verify]#"/>
- <link rel="search" href="http://#[thisaddress]#/opensearchdescription.xml" type="application/opensearchdescription+xml"/>
+ <link rel="search" href="#[thisaddress]#/opensearchdescription.xml" type="application/opensearchdescription+xml"/>
<opensearch:Query role="request" searchTerms="#[rss_queryenc]#" />
<id>http://#[clientid]#.yacyh/</id>
diff --git a/htroot/yacysearch.html b/htroot/yacysearch.html
index 536eba0c3..513dafe18 100644
--- a/htroot/yacysearch.html
+++ b/htroot/yacysearch.html
@@ -4,7 +4,7 @@
<title>#[former]# - YaCy '#[clientname]#': Search Page</title>
#%env/templates/metas.template%#
<link rel="alternate" type="application/rss+xml" title="Search for #[former]#" href="yacysearch.rss?query=#[formerEncoded]#" />
- <link rel="search" type="application/opensearchdescription+xml" title="YaCy '#[clientname]#'" href="http://#[thisaddress]#/opensearchdescription.xml" />
+ <link rel="search" type="application/opensearchdescription+xml" title="YaCy '#[clientname]#'" href="#[thisaddress]#/opensearchdescription.xml" />
<link rel="stylesheet" type="text/css" media="screen" href="env/highslide.css" />
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript" src="js/xml.js"></script>
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index a63260899..65556b81d 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -65,6 +65,7 @@ import net.yacy.data.UserDB;
import net.yacy.data.ymark.YMarkTables;
import net.yacy.document.LibraryProvider;
import net.yacy.document.Tokenizer;
+import net.yacy.http.servlets.YaCyDefaultServlet;
import net.yacy.kelondro.data.meta.URIMetadataNode;
import net.yacy.kelondro.util.Bitfield;
import net.yacy.kelondro.util.Formatter;
@@ -147,13 +148,10 @@ public class yacysearch {
prop.put("promoteSearchPageGreeting", promoteSearchPageGreeting);
// adding some additional properties needed for the rss feed
- String hostName = header.get("Host", Domains.LOCALHOST);
- if ( hostName.indexOf(':', 0) == -1 ) {
- hostName += ":" + env.getLocalPort();
- }
- prop.put("searchBaseURL", "http://" + hostName + "/yacysearch.html");
- prop.put("rssYacyImageURL", "http://" + hostName + "/env/grafics/yacy.png");
- prop.put("thisaddress", hostName);
+ String peerContext = YaCyDefaultServlet.getContext(header, sb);
+ prop.put("searchBaseURL", peerContext + "/yacysearch.html");
+ prop.put("rssYacyImageURL", peerContext + "/env/grafics/yacy.png");
+ prop.put("thisaddress", peerContext);
final boolean clustersearch = sb.isRobinsonMode() && sb.getConfig(SwitchboardConstants.CLUSTER_MODE, "").equals(SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER);
final boolean indexReceiveGranted = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, true) || clustersearch;
boolean p2pmode = sb.peers != null && sb.peers.sizeConnected() > 0 && indexReceiveGranted;
@@ -879,11 +877,6 @@ public class yacysearch {
sb.localSearchLastAccess = System.currentTimeMillis();
- // hostname and port (assume locahost if nothing helps)
- final String hostIP = sb.peers.mySeed().getIP();
- prop.put("myhost", hostIP != null ? hostIP : Domains.LOCALHOST);
- prop.put("myport", Domains.LOCALHOST.equals(hostIP) ? sb.getLocalPort() : sb.getPublicPort("port", 8090));
-
// return rewrite properties
return prop;
}
diff --git a/htroot/yacysearch.rss b/htroot/yacysearch.rss
index ded55e396..9513be15a 100644
--- a/htroot/yacysearch.rss
+++ b/htroot/yacysearch.rss
@@ -21,7 +21,7 @@
</image>
<opensearch:startIndex>#[num-results_offset]#</opensearch:startIndex>
<opensearch:itemsPerPage>#[num-results_itemsPerPage]#</opensearch:itemsPerPage>
- <atom:link rel="search" href="http://#[thisaddress]#/opensearchdescription.xml" type="application/opensearchdescription+xml"/>
+ <atom:link rel="search" href="#[thisaddress]#/opensearchdescription.xml" type="application/opensearchdescription+xml"/>
<opensearch:Query role="request" searchTerms="#[rss_queryenc]#" />
#{results}#
<!--#include virtual="yacysearchitem.xml?item=#[item]#&eventID=#[eventID]#" -->