Skip to content

Commit

Permalink
*) No stacktrace anymore if invalid regex is entered in search box, i…
Browse files Browse the repository at this point in the history
…nsted 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
  • Loading branch information
low012 committed Jun 25, 2007
1 parent 6b4cfbd commit b96386e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions htroot/Network.html
Expand Up @@ -31,6 +31,10 @@ <h2>Potential Peers in '#[networkName]#' Network</h2>
::
<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>
::
Expand Down
15 changes: 13 additions & 2 deletions htroot/Network.java
Expand Up @@ -53,6 +53,7 @@
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;
Expand Down Expand Up @@ -307,13 +308,23 @@ record = yacyCore.newsPool.get(yacyNewsPool.INCOMING_DB, c);
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 ()) {
Expand Down

0 comments on commit b96386e

Please sign in to comment.