Skip to content

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

*) used regexp to recognize invalid peer-names

auron_x6cca0ee98d8f
diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.java
index 0657309ff..af1556771 100644
--- a/htroot/ConfigBasic.java
+++ b/htroot/ConfigBasic.java
@@ -49,6 +49,8 @@
import java.io.File;
import java.lang.reflect.Method;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import de.anomic.data.translator;
import de.anomic.http.httpHeader;
@@ -150,13 +152,9 @@ public class ConfigBasic {
// check if peer name already exists
yacySeed oldSeed = yacyCore.seedDB.lookupByName(peerName);
- if ((peerName.length() >= 3) && (oldSeed == null) && (!(env.getConfig("peerName", "").equals(peerName)))) {
+ if ((oldSeed == null) && (!(env.getConfig("peerName", "").equals(peerName)))) {
// the name is new
- boolean nameOK = (peerName.length() <= 80);
- for (int i = 0; i < peerName.length(); i++) {
- if ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_".indexOf(peerName.charAt(i)) < 0)
- nameOK = false;
- }
+ boolean nameOK = Pattern.compile("[A-Za-z0-9\\-_]{3,80}").matcher(peerName).matches();
if (nameOK) env.setConfig("peerName", peerName);
}