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:
ray
2005-03-10 22:29:50 +00:00
parent 24ecdee051
commit 35aa668b87
@@ -150,8 +150,9 @@ public class StringUtil
/**
* Restrict HTML except for the specified tags.
*
* @param allowFormatting enables &lt;i&gt;, &lt;b&gt;, &lt;u&gt;, and
* &lt;font&gt;.
* @param allowFormatting enables &lt;i&gt;, &lt;b&gt;, &lt;u&gt;,
* &lt;font&gt;, &lt;br&gt;, &lt;p&gt;, and
* &lt;hr&gt;.
* @param allowImages enabled &lt;img ...&gt;.
* @param allowLinks enabled &lt;a href ...&gt;.
*/
@@ -165,13 +166,16 @@ public class StringUtil
allow.add("<b>"); allow.add("</b>");
allow.add("<i>"); allow.add("</i>");
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) {
allow.add("<img [^>]+>"); allow.add("</img>");
allow.add("<img [^<>]+>"); allow.add("</img>");
}
if (allowLinks) {
allow.add("<a href=[^>]+>"); allow.add("</a>");
allow.add("<a href=[^<>]+>"); allow.add("</a>");
}
String[] regexes = new String[allow.size()];