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

This has no effect on Network.xml which will present all peernames if an invalid regex is entered now. I'm not sure if this is a desired behavior or if it was better to not return any results at all. Any suggestions?


git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3923 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
low012 18 years ago
parent 6b4cfbd2d6
commit b96386e3da

@ -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>
::

@ -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 ()) {

Loading…
Cancel
Save