|
|
|
@ -121,7 +121,7 @@ public final class HtmlFilter {
|
|
|
|
|
vSelfClosingTags = new String[]{"img"};
|
|
|
|
|
vNeedClosingTags = new String[]{"a", "b", "strong", "i", "em"};
|
|
|
|
|
vDisallowed = new String[]{};
|
|
|
|
|
vAllowedProtocols = new String[]{"http", "mailto", "https"}; // no ftp.
|
|
|
|
|
vAllowedProtocols = new String[]{"http", "mailto", "https"};
|
|
|
|
|
vProtocolAtts = new String[]{"src", "href"};
|
|
|
|
|
vRemoveBlanks = new String[]{"a", "b", "strong", "i", "em"};
|
|
|
|
|
vAllowedEntities = new String[]{"amp", "gt", "lt", "quot"};
|
|
|
|
@ -221,7 +221,7 @@ public final class HtmlFilter {
|
|
|
|
|
final Matcher m = P_COMMENTS.matcher(s);
|
|
|
|
|
final StringBuffer buf = new StringBuffer();
|
|
|
|
|
if (m.find()) {
|
|
|
|
|
final String match = m.group(1); // (.*?)
|
|
|
|
|
final String match = m.group(1);
|
|
|
|
|
m.appendReplacement(buf, Matcher.quoteReplacement("<!--" + htmlSpecialChars(match) + "-->"));
|
|
|
|
|
}
|
|
|
|
|
m.appendTail(buf);
|
|
|
|
@ -329,12 +329,12 @@ public final class HtmlFilter {
|
|
|
|
|
final List<String> paramNames = new ArrayList<>();
|
|
|
|
|
final List<String> paramValues = new ArrayList<>();
|
|
|
|
|
while (m2.find()) {
|
|
|
|
|
paramNames.add(m2.group(1)); // ([a-z0-9]+)
|
|
|
|
|
paramValues.add(m2.group(3)); // (.*?)
|
|
|
|
|
paramNames.add(m2.group(1));
|
|
|
|
|
paramValues.add(m2.group(3));
|
|
|
|
|
}
|
|
|
|
|
while (m3.find()) {
|
|
|
|
|
paramNames.add(m3.group(1)); // ([a-z0-9]+)
|
|
|
|
|
paramValues.add(m3.group(3)); // ([^\"\\s']+)
|
|
|
|
|
paramNames.add(m3.group(1));
|
|
|
|
|
paramValues.add(m3.group(3));
|
|
|
|
|
}
|
|
|
|
|
String paramName, paramValue;
|
|
|
|
|
for (int ii = 0; ii < paramNames.size(); ii++) {
|
|
|
|
@ -434,8 +434,8 @@ public final class HtmlFilter {
|
|
|
|
|
// validate entities throughout the string
|
|
|
|
|
Matcher m = P_VALID_ENTITIES.matcher(s);
|
|
|
|
|
while (m.find()) {
|
|
|
|
|
final String one = m.group(1); // ([^&;]*)
|
|
|
|
|
final String two = m.group(2); // (?=(;|&|$))
|
|
|
|
|
final String one = m.group(1);
|
|
|
|
|
final String two = m.group(2);
|
|
|
|
|
m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two)));
|
|
|
|
|
}
|
|
|
|
|
m.appendTail(buf);
|
|
|
|
@ -448,10 +448,10 @@ public final class HtmlFilter {
|
|
|
|
|
StringBuffer buf = new StringBuffer();
|
|
|
|
|
Matcher m = P_VALID_QUOTES.matcher(s);
|
|
|
|
|
while (m.find()) {
|
|
|
|
|
final String one = m.group(1); // (>|^)
|
|
|
|
|
final String two = m.group(2); // ([^<]+?)
|
|
|
|
|
final String three = m.group(3); // (<|$)
|
|
|
|
|
// 不替换双引号为",防止json格式无效 regexReplace(P_QUOTE, """, two)
|
|
|
|
|
final String one = m.group(1);
|
|
|
|
|
final String two = m.group(2);
|
|
|
|
|
final String three = m.group(3);
|
|
|
|
|
/*不替换双引号为",防止json格式无效 regexReplace(P_QUOTE, """, two)*/
|
|
|
|
|
m.appendReplacement(buf, Matcher.quoteReplacement(one + two + three));
|
|
|
|
|
}
|
|
|
|
|
m.appendTail(buf);
|
|
|
|
|