Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Fixed some HTML validation errors : Illegal character in query
luccioman60df09fff90f
diff --git a/htroot/yacysearch.html b/htroot/yacysearch.htmlindex a3df1c19a..aa560b981 100644--- a/htroot/yacysearch.html+++ b/htroot/yacysearch.html@@ -3,7 +3,7 @@<head><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=#[former]#" />+ <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="stylesheet" type="text/css" media="screen" href="env/highslide.css" /><script type="text/javascript" src="js/ajax.js"></script>diff --git a/htroot/yacysearch.java b/htroot/yacysearch.javaindex fd8e604e1..a63260899 100644--- a/htroot/yacysearch.java+++ b/htroot/yacysearch.java@@ -28,6 +28,9 @@// if the shell's current path is HTROOTimport java.io.IOException;+import java.io.UnsupportedEncodingException;+import java.net.URLEncoder;+import java.nio.charset.StandardCharsets;import java.util.ArrayList;import java.util.Collection;import java.util.ConcurrentModificationException;@@ -852,7 +855,14 @@ public class yacysearch {}prop.put("focus", focus ? 1 : 0); // focus search fieldprop.put("searchagain", global ? "1" : "0");- prop.putHTML("former", originalquerystring.replaceAll(Segment.catchallString, "*"));+ String former = originalquerystring.replaceAll(Segment.catchallString, "*");+ prop.putHTML("former", former);+ try {+ prop.put("formerEncoded", URLEncoder.encode(former, StandardCharsets.UTF_8.name()));+ } catch (UnsupportedEncodingException e) {+ ConcurrentLog.warn("LOCAL_SEARCH", "Unsupported UTF-8 encoding!");+ prop.put("formerEncoded", former);+ }prop.put("count", itemsPerPage);prop.put("offset", startRecord);prop.put("resource", global ? "global" : "local");@@ -877,4 +887,8 @@ public class yacysearch {// return rewrite propertiesreturn prop;}++ public static void main(String args[]) throws UnsupportedEncodingException {+ System.out.println(URLEncoder.encode("aao?+ bbibu", StandardCharsets.UTF_8.name()));+ }}diff --git a/htroot/yacysearchtrailer.java b/htroot/yacysearchtrailer.javaindex d60994fa7..a2f8d74a3 100644--- a/htroot/yacysearchtrailer.java+++ b/htroot/yacysearchtrailer.java@@ -110,7 +110,8 @@ public class yacysearchtrailer {name = navigatorIterator.next();count = theSearch.namespaceNavigator.get(name);if (count == 0) break;- nav = "inurl%3A" + name;+ /* We use ':' character here, it will be percent encoded later, in QueryParams.navurl() function*/+ nav = "inurl:" + name;if (!theSearch.query.modifier.toString().contains("inurl:"+name)) {pos++;prop.put("nav-namespace_element_" + i + "_on", 1);@@ -317,7 +318,7 @@ public class yacysearchtrailer {prop.put("nav-topics_element_" + i + "_on", 1);prop.put(fileType, "nav-topics_element_" + i + "_modifier", name);prop.put(fileType, "nav-topics_element_" + i + "_name", name);- prop.put(fileType, "nav-topics_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, name, false).toString());+ prop.put("nav-topics_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, name, false).toString());prop.put("nav-topics_element_" + i + "_count", count);int fontsize = TOPWORDS_MINSIZE + (TOPWORDS_MAXSIZE - TOPWORDS_MINSIZE) * (count - mincount) / (1 + maxcount - mincount);fontsize = Math.max(TOPWORDS_MINSIZE, fontsize - (name.length() - 5));diff --git a/source/net/yacy/search/query/QueryParams.java b/source/net/yacy/search/query/QueryParams.javaindex aac1a2866..3a27dd74e 100644--- a/source/net/yacy/search/query/QueryParams.java+++ b/source/net/yacy/search/query/QueryParams.java@@ -26,6 +26,9 @@package net.yacy.search.query;+import java.io.UnsupportedEncodingException;+import java.net.URLEncoder;+import java.nio.charset.StandardCharsets;import java.util.ArrayList;import java.util.Collection;import java.util.Date;@@ -702,7 +705,7 @@ public final class QueryParams {if (!newModifier.isEmpty()) {if (!theQuery.modifier.isEmpty()) sb.append("+" + theQuery.modifier.toString());if (newModifierReplacesOld) {- int nmpi = newModifier.indexOf("%3A");+ int nmpi = newModifier.indexOf(":");if (nmpi > 0) {String nmp = newModifier.substring(0, nmpi) + ":";int i = sb.indexOf(nmp);@@ -710,7 +713,11 @@ public final class QueryParams {if (sb.charAt(sb.length() - 1) == '+') sb.setLength(sb.length() - 1);}}- sb.append("+" + newModifier);+ try {+ sb.append("+" + URLEncoder.encode(newModifier, StandardCharsets.UTF_8.name()));+ } catch (final UnsupportedEncodingException e) {+ sb.append("+" + newModifier);+ }}}