From e25c1f2ea3a66b78523569094fba74ee5da9ba2c Mon Sep 17 00:00:00 2001 From: low012 Date: Sat, 2 Apr 2011 09:25:07 +0000 Subject: [PATCH] *) preventing whitespace keys in config file git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7637 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/ConfigProperties_p.java | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/htroot/ConfigProperties_p.java b/htroot/ConfigProperties_p.java index e5b79483f..3b60a51b2 100644 --- a/htroot/ConfigProperties_p.java +++ b/htroot/ConfigProperties_p.java @@ -1,4 +1,4 @@ -// ConfigGeneric_p.java +// ConfigProperties_p.java // ----------------------- // part of YaCy // (C) by Michael Peter Christen; mc@yacy.net @@ -43,29 +43,30 @@ public class ConfigProperties_p { public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) { // return variable that accumulates replacements final serverObjects prop = new serverObjects(); - int count = 0; + String key; //change a key - if(post != null && post.containsKey("key") && post.containsKey("value")){ - key = post.get("key"); - final String value = post.get("value"); - if (!"".equals(key)) { - env.setConfig(key, value); + if (post != null && post.containsKey("key") && post.containsKey("value")) { + key = post.get("key").trim(); + if (key != null && !key.isEmpty()) { + env.setConfig(key, post.get("value").trim()); } } + Iterator keys = env.configKeys(); final List list = new ArrayList(250); - while(keys.hasNext()){ + while (keys.hasNext()) { list.add(keys.next()); } - + Collections.sort(list); - + + int count = 0; keys = list.iterator(); - while(keys.hasNext()){ + while (keys.hasNext()) { key = keys.next(); // only display lines if they are no commment