From 6cca0ee98d8fbbe200e845b13e389e6244de0e99 Mon Sep 17 00:00:00 2001 From: auron_x Date: Mon, 20 Nov 2006 20:03:05 +0000 Subject: [PATCH] *) used regexp to recognize invalid peer-names git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2992 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/ConfigBasic.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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); }