*) used regexp to recognize invalid peer-names

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2992 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
auron_x 18 years ago
parent af4bca5fc7
commit 6cca0ee98d

@ -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);
}

Loading…
Cancel
Save