Skip to content

Commit

Permalink
- fix for use of Java 1.5 methods (eclipse is crap)
Browse files Browse the repository at this point in the history
- added two more test-cases for blacklist cleaner

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3288 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
karlchenofhell committed Jan 28, 2007
1 parent cd86e78 commit c83b156
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
4 changes: 3 additions & 1 deletion htroot/BlacklistCleaner_p.html
Expand Up @@ -35,7 +35,9 @@ <h2>Blacklist Cleaner</h2>
<dl>
#{entries}#
<dt>
<label for="select#[entry]#" class="error">#(error)#Two wildcards in host-part::Either subdomain <u>or</u> wildcard::Path is invalid Regex#(/error)#</label>
<label for="select#[entry]#" class="error">
#(error)#Two wildcards in host-part::Either subdomain <u>or</u> wildcard::Path is invalid Regex::Wildcard not on begin or end::Host contains illegal chars#(/error)#
</label>
<input type="checkbox" name="select#[entry]#" id="select#[entry]#" checked="checked" />
</dt>
<dd><input type="text" name="entry#[entry]#" value="#[entry]#" size="50" /></dd>
Expand Down
35 changes: 24 additions & 11 deletions htroot/BlacklistCleaner_p.java
Expand Up @@ -73,6 +73,8 @@ public class BlacklistCleaner_p {
private static final int ERR_TWO_WILDCARDS_IN_HOST = 0;
private static final int ERR_SUBDOMAIN_XOR_WILDCARD = 1;
private static final int ERR_PATH_REGEX = 2;
private static final int ERR_WILDCARD_BEGIN_OR_END = 3;
private static final int ERR_HOST_WRONG_CHARS = 4;

public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
serverObjects prop = new serverObjects();
Expand Down Expand Up @@ -123,7 +125,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
String s;
while (it.hasNext()) {
s = (String)it.next();
prop.put(RESULTS + DISABLED + ENTRIES + i + "_error", ((Integer)ies.get(s)).intValue());
prop.put(RESULTS + DISABLED + ENTRIES + i + "_error", ((Integer)ies.get(s)).longValue());
prop.putSafeXML(RESULTS + DISABLED + ENTRIES + i + "_entry", s);
i++;
}
Expand Down Expand Up @@ -177,18 +179,29 @@ private static String[] getByPrefix(serverObjects post, String prefix) {
}

int i = host.indexOf("*");

// check whether host begins illegally
if (!host.matches("([A-Za-z0-9_-]+|\\*)(\\.([A-Za-z0-9_-]+|\\*))*")) {
if (i == 0 && host.length() > 1 && host.charAt(1) != '.') {
r.put(s, new Integer(ERR_SUBDOMAIN_XOR_WILDCARD));
continue;
} else {
r.put(s, new Integer(ERR_HOST_WRONG_CHARS));
continue;
}
}

// in host-part only full sub-domains may be wildcards
if (host.length() > 0 && i > -1) {
if (host.length() > i + 1)
if (host.charAt(i + 1) != '.') {
r.put(s, Integer.valueOf(ERR_SUBDOMAIN_XOR_WILDCARD));
continue;
}
if (i > 0)
if (host.charAt(i - 1) != '.') {
r.put(s, Integer.valueOf(ERR_SUBDOMAIN_XOR_WILDCARD));
continue;
}
if (!(i == 0 || i == host.length() - 1)) {
r.put(s, new Integer(ERR_WILDCARD_BEGIN_OR_END));
continue;
}

if (i == host.length() - 1 && host.length() > 1 && host.charAt(i - 1) != '.') {
r.put(s, new Integer(ERR_SUBDOMAIN_XOR_WILDCARD));
continue;
}
}

// check for double-occurences of "*" in host
Expand Down

0 comments on commit c83b156

Please sign in to comment.