More HTML restriction: block "<" from appearing in font, img, a href,
and added <br>, <p>, and <hr> to the 'formatting' common regexes. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1612 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -150,8 +150,9 @@ public class StringUtil
|
|||||||
/**
|
/**
|
||||||
* Restrict HTML except for the specified tags.
|
* Restrict HTML except for the specified tags.
|
||||||
*
|
*
|
||||||
* @param allowFormatting enables <i>, <b>, <u>, and
|
* @param allowFormatting enables <i>, <b>, <u>,
|
||||||
* <font>.
|
* <font>, <br>, <p>, and
|
||||||
|
* <hr>.
|
||||||
* @param allowImages enabled <img ...>.
|
* @param allowImages enabled <img ...>.
|
||||||
* @param allowLinks enabled <a href ...>.
|
* @param allowLinks enabled <a href ...>.
|
||||||
*/
|
*/
|
||||||
@@ -165,13 +166,16 @@ public class StringUtil
|
|||||||
allow.add("<b>"); allow.add("</b>");
|
allow.add("<b>"); allow.add("</b>");
|
||||||
allow.add("<i>"); allow.add("</i>");
|
allow.add("<i>"); allow.add("</i>");
|
||||||
allow.add("<u>"); allow.add("</u>");
|
allow.add("<u>"); allow.add("</u>");
|
||||||
allow.add("<font [^>]+>"); allow.add("</font>");
|
allow.add("<font [^<>]+>"); allow.add("</font>");
|
||||||
|
allow.add("<br>"); allow.add("</br>");
|
||||||
|
allow.add("<p>"); allow.add("</p>");
|
||||||
|
allow.add("<hr>"); allow.add("</hr>");
|
||||||
}
|
}
|
||||||
if (allowImages) {
|
if (allowImages) {
|
||||||
allow.add("<img [^>]+>"); allow.add("</img>");
|
allow.add("<img [^<>]+>"); allow.add("</img>");
|
||||||
}
|
}
|
||||||
if (allowLinks) {
|
if (allowLinks) {
|
||||||
allow.add("<a href=[^>]+>"); allow.add("</a>");
|
allow.add("<a href=[^<>]+>"); allow.add("</a>");
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] regexes = new String[allow.size()];
|
String[] regexes = new String[allow.size()];
|
||||||
|
|||||||
Reference in New Issue
Block a user