This commit is contained in:
jrandom
2005-11-11 10:09:04 +00:00
committed by zzz
parent a8ea239dcc
commit 12ddaff0ce
3 changed files with 22 additions and 17 deletions

View File

@ -900,7 +900,9 @@ public class HTMLRenderer extends EventReceiverImpl {
}
public static final String sanitizeString(String str) { return sanitizeString(str, true); }
public static final String sanitizeString(String str, boolean allowNL) {
public static final String sanitizeString(String str, int maxLen) { return sanitizeString(str, true, maxLen); }
public static final String sanitizeString(String str, boolean allowNL) { return sanitizeString(str, allowNL, -1); }
public static final String sanitizeString(String str, boolean allowNL, int maxLen) {
if (str == null) return null;
boolean unsafe = false;
unsafe = unsafe || str.indexOf('<') >= 0;
@ -910,8 +912,7 @@ public class HTMLRenderer extends EventReceiverImpl {
unsafe = unsafe || str.indexOf('\r') >= 0;
unsafe = unsafe || str.indexOf('\f') >= 0;
}
if (!unsafe) return str;
if (unsafe) {
//str = str.replace('<', '_'); // this should be &lt;
//str = str.replace('>', '-'); // this should be &gt;
str = str.replaceAll("<", "&lt;");
@ -924,6 +925,10 @@ public class HTMLRenderer extends EventReceiverImpl {
str = str.replaceAll("\r", "<br />"); // no class
str = str.replaceAll("\f", "<br />"); // no class
}
}
if ( (maxLen > 0) && (str.length() > maxLen) )
return str.substring(0, maxLen) + "...";
else
return str;
}

View File

@ -294,7 +294,7 @@ public class ThreadedHTMLRenderer extends HTMLRenderer {
_postBodyBuffer.append("schema=").append(sanitizeURL(l.schema)).append('&');
if (l.location != null)
_postBodyBuffer.append("location=").append(sanitizeURL(l.location)).append('&');
_postBodyBuffer.append("\">").append(sanitizeString(l.location));
_postBodyBuffer.append("\">").append(sanitizeString(l.location, 60));
_postBodyBuffer.append(getSpan("summDetailExternalNet")).append(" (").append(sanitizeString(l.schema)).append(")</span></a> ");
}
_postBodyBuffer.append("<br />\n");

View File

@ -32,7 +32,7 @@ public class PetName {
_groups = new ArrayList();
StringTokenizer tok = new StringTokenizer(dbLine, ":\n", true);
int tokens = tok.countTokens();
System.out.println("Tokens: " + tokens);
//System.out.println("Tokens: " + tokens);
if (tokens < 7) {
return;
}