Skip to content

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

*) No stacktrace anymore if invalid regex is entered in search box, insted an error message gets displayed.

low012b96386e3da4c
diff --git a/htroot/Network.html b/htroot/Network.html
index 1c82147d7..aedc41c1a 100644
--- a/htroot/Network.html
+++ b/htroot/Network.html
@@ -31,6 +31,10 @@
::
<h2>Manually contacting Peer</h2>
#(/page)#
+ #(regexerror)#
+ ::
+ <p><strong>ERROR</strong>: Unable to execute query. &quot;<strong>#[wrongregex]#</strong>&quot; is no valid regular expression, please enter a valid regular expression to search for a peername.</p>
+ #(/regexerror)#
#(table)#
<p>no remote #[peertype]# peer for this list known</p>
::
diff --git a/htroot/Network.java b/htroot/Network.java
index 827fa1c68..e6a274e76 100644
--- a/htroot/Network.java
+++ b/htroot/Network.java
@@ -53,6 +53,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
import de.anomic.http.httpHeader;
import de.anomic.http.httpc;
@@ -307,13 +308,23 @@ public class Network {
double QPM;
long myValue=0, nextValue=0, prevValue=0, nextPPM=0, myPPM=0;
Pattern peerSearchPattern = null;
+ String wrongregex = null;
+ prop.put("regexerror", 0);
+ prop.put("wrongregex", (String)null);
if(post.containsKey("search")) {
- peerSearchPattern = Pattern.compile(post.get("match", ""), Pattern.CASE_INSENSITIVE);
+ try{
+ peerSearchPattern = Pattern.compile(post.get("match", ""), Pattern.CASE_INSENSITIVE);
+ }
+ catch (PatternSyntaxException pse){
+ wrongregex = pse.getPattern();
+ prop.put("regexerror", 1);
+ prop.put("regexerror_wrongregex", wrongregex);
+ }
}
while (e.hasMoreElements() && conCount < maxCount) {
seed = (yacySeed) e.nextElement();
if (seed != null) {
- if(post.containsKey("search")) {
+ if((post.containsKey("search")) && (wrongregex == null)) {
boolean abort = true;
Matcher m = peerSearchPattern.matcher (seed.getName());
if (m.find ()) {