Skip to content

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

*) No stacktrace anymore if invalid regex is entered for URL mask or Prefer mask, insted an error message gets displayed.

low012f603b58f6c86
diff --git a/htroot/yacysearch.html b/htroot/yacysearch.html
index e79943b2f..eea25b372 100644
--- a/htroot/yacysearch.html
+++ b/htroot/yacysearch.html
@@ -88,6 +88,8 @@ document.getElementById("Enter").value = "search again - catch up more links";
then please run your own peer and start a crawl of your wanted information to make it
available for everyone. Then stay online to support crawls from other peers. Thank you!</p>
::
+ <p>No Results. &quot;<strong>#[wrong_regex]#</strong>&quot; is no valid regular expression, please go back to the previous page and make sure to enter a valid regular expressions for URL mask and Prefer mask.</p>
+ ::
<p><strong>#[linkcount]#</strong> results from <strong>#[orderedcount]#</strong> ordered links from <strong>#[filteredcount]#</strong> filtered links of a total number of <strong>#[totalcount]#</strong> known.</p>
#(/num-results)#
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index 25059d1e4..bf39f1aba 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -52,6 +52,7 @@ import java.net.MalformedURLException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.regex.PatternSyntaxException;
import java.util.TreeSet;
import de.anomic.htmlFilter.htmlFilterImageEntry;
@@ -267,8 +268,16 @@ public class yacysearch {
plasmaSearchRankingProfile ranking = (sb.getConfig("rankingProfile", "").length() == 0) ? new plasmaSearchRankingProfile(contentdomString) : new plasmaSearchRankingProfile("", crypt.simpleDecode(sb.getConfig("rankingProfile", ""), null));
plasmaSearchTimingProfile localTiming = new plasmaSearchTimingProfile(4 * thisSearch.maximumTime / 10, thisSearch.wantedResults);
plasmaSearchTimingProfile remoteTiming = new plasmaSearchTimingProfile(6 * thisSearch.maximumTime / 10, thisSearch.wantedResults);
-
- plasmaSearchResults results = sb.searchFromLocal(thisSearch, ranking, localTiming, remoteTiming, true, (String) header.get("CLIENTIP"));
+
+ plasmaSearchResults results = new plasmaSearchResults();
+ String wrongregex = null;
+ try{
+ results = sb.searchFromLocal(thisSearch, ranking, localTiming, remoteTiming, true, (String) header.get("CLIENTIP"));
+ }
+ catch(PatternSyntaxException e){
+ wrongregex = e.getPattern();
+ }
+
//prop=sb.searchFromLocal(thisSearch, ranking, localTiming, remoteTiming, true, (String) header.get("CLIENTIP"));
prop=new serverObjects();
//prop.put("references", 0);
@@ -395,15 +404,23 @@ public class yacysearch {
}
}
} else {
- if (totalcount == 0) {
- prop.put("num-results", 3); // long
- } else {
+ if (wrongregex != null) {
+ prop.put("num-results_wrong_regex", wrongregex);
prop.put("num-results", 4);
}
+ else if (totalcount == 0) {
+ prop.put("num-results", 3); // long
+ }
+ else {
+ prop.put("num-results", 5);
+ }
}
}
- if (yacyonline) {
+ if (wrongregex != null) {
+ prop.put("type_resultbottomline", 0);
+ }
+ else if (yacyonline) {
if (global) {
prop.put("type_resultbottomline", 1);
prop.put("type_resultbottomline_globalresults", prop.get("num-results_globalresults", "0"));