I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 12ddaff0 authored by jrandom's avatar jrandom Committed by zzz
Browse files

..

parent a8ea239d
No related branches found
No related tags found
No related merge requests found
...@@ -900,7 +900,9 @@ public class HTMLRenderer extends EventReceiverImpl { ...@@ -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) { 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; if (str == null) return null;
boolean unsafe = false; boolean unsafe = false;
unsafe = unsafe || str.indexOf('<') >= 0; unsafe = unsafe || str.indexOf('<') >= 0;
...@@ -910,21 +912,24 @@ public class HTMLRenderer extends EventReceiverImpl { ...@@ -910,21 +912,24 @@ public class HTMLRenderer extends EventReceiverImpl {
unsafe = unsafe || str.indexOf('\r') >= 0; unsafe = unsafe || str.indexOf('\r') >= 0;
unsafe = unsafe || str.indexOf('\f') >= 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 &lt; //str = str.replace('>', '-'); // this should be &gt;
//str = str.replace('>', '-'); // this should be &gt; str = str.replaceAll("<", "&lt;");
str = str.replaceAll("<", "&lt;"); str = str.replaceAll(">", "&gt;");
str = str.replaceAll(">", "&gt;"); if (!allowNL) {
if (!allowNL) { //str = str.replace('\n', ' ');
//str = str.replace('\n', ' '); //str = str.replace('\r', ' ');
//str = str.replace('\r', ' '); //str = str.replace('\f', ' ');
//str = str.replace('\f', ' '); str = str.replaceAll("\n", "<br />"); // no class
str = str.replaceAll("\n", "<br />"); // no class str = str.replaceAll("\r", "<br />"); // no class
str = str.replaceAll("\r", "<br />"); // no class str = str.replaceAll("\f", "<br />"); // no class
str = str.replaceAll("\f", "<br />"); // no class }
} }
return str; if ( (maxLen > 0) && (str.length() > maxLen) )
return str.substring(0, maxLen) + "...";
else
return str;
} }
public static final String sanitizeURL(String str) { public static final String sanitizeURL(String str) {
......
...@@ -294,7 +294,7 @@ public class ThreadedHTMLRenderer extends HTMLRenderer { ...@@ -294,7 +294,7 @@ public class ThreadedHTMLRenderer extends HTMLRenderer {
_postBodyBuffer.append("schema=").append(sanitizeURL(l.schema)).append('&'); _postBodyBuffer.append("schema=").append(sanitizeURL(l.schema)).append('&');
if (l.location != null) if (l.location != null)
_postBodyBuffer.append("location=").append(sanitizeURL(l.location)).append('&'); _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(getSpan("summDetailExternalNet")).append(" (").append(sanitizeString(l.schema)).append(")</span></a> ");
} }
_postBodyBuffer.append("<br />\n"); _postBodyBuffer.append("<br />\n");
......
...@@ -32,7 +32,7 @@ public class PetName { ...@@ -32,7 +32,7 @@ public class PetName {
_groups = new ArrayList(); _groups = new ArrayList();
StringTokenizer tok = new StringTokenizer(dbLine, ":\n", true); StringTokenizer tok = new StringTokenizer(dbLine, ":\n", true);
int tokens = tok.countTokens(); int tokens = tok.countTokens();
System.out.println("Tokens: " + tokens); //System.out.println("Tokens: " + tokens);
if (tokens < 7) { if (tokens < 7) {
return; return;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment