优化匹配方式

pull/484/head
RuoYi 2024-02-29 14:13:38 +08:00
parent 0ce40fc039
commit bcb6222c61
1 changed files with 6 additions and 1 deletions

View File

@ -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();
}
}