优化匹配方式
This commit is contained in:
parent
e9ae7ae5f3
commit
649cfe8652
|
@ -27,8 +27,13 @@ public class XssValidator implements ConstraintValidator<Xss, String>
|
|||
|
||||
public static boolean containsHtml(String value)
|
||||
{
|
||||
StringBuilder sHtml = new StringBuilder();
|
||||
Pattern pattern = Pattern.compile(HTML_PATTERN);
|
||||
Matcher matcher = pattern.matcher(value);
|
||||
return matcher.matches();
|
||||
while (matcher.find())
|
||||
{
|
||||
sHtml.append(matcher.group());
|
||||
}
|
||||
return pattern.matcher(sHtml).matches();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue