Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
RuoYi Vue
Commits
50236ae4
Commit
50236ae4
authored
Feb 10, 2022
by
RuoYi
Browse files
修复Xss注解字段值为空时的异常问题
parent
612c4293
Changes
2
Hide whitespace changes
Inline
Side-by-side
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
View file @
50236ae4
...
@@ -88,7 +88,6 @@ public class ExcelUtil<T>
...
@@ -88,7 +88,6 @@ public class ExcelUtil<T>
public
static
final
String
[]
FORMULA_STR
=
{
"="
,
"-"
,
"+"
,
"@"
};
public
static
final
String
[]
FORMULA_STR
=
{
"="
,
"-"
,
"+"
,
"@"
};
/**
/**
* Excel sheet最大行数,默认65536
* Excel sheet最大行数,默认65536
*/
*/
...
...
ruoyi-common/src/main/java/com/ruoyi/common/xss/XssValidator.java
View file @
50236ae4
package
com.ruoyi.common.xss
;
package
com.ruoyi.common.xss
;
import
com.ruoyi.common.utils.StringUtils
;
import
javax.validation.ConstraintValidator
;
import
javax.validation.ConstraintValidator
;
import
javax.validation.ConstraintValidatorContext
;
import
javax.validation.ConstraintValidatorContext
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
...
@@ -12,15 +13,19 @@ import java.util.regex.Pattern;
...
@@ -12,15 +13,19 @@ import java.util.regex.Pattern;
*/
*/
public
class
XssValidator
implements
ConstraintValidator
<
Xss
,
String
>
public
class
XssValidator
implements
ConstraintValidator
<
Xss
,
String
>
{
{
private
final
String
HTML_PATTERN
=
"<(\\S*?)[^>]*>.*?|<.*? />"
;
private
static
final
String
HTML_PATTERN
=
"<(\\S*?)[^>]*>.*?|<.*? />"
;
@Override
@Override
public
boolean
isValid
(
String
value
,
ConstraintValidatorContext
constraintValidatorContext
)
public
boolean
isValid
(
String
value
,
ConstraintValidatorContext
constraintValidatorContext
)
{
{
if
(
StringUtils
.
isBlank
(
value
))
{
return
true
;
}
return
!
containsHtml
(
value
);
return
!
containsHtml
(
value
);
}
}
public
boolean
containsHtml
(
String
value
)
public
static
boolean
containsHtml
(
String
value
)
{
{
Pattern
pattern
=
Pattern
.
compile
(
HTML_PATTERN
);
Pattern
pattern
=
Pattern
.
compile
(
HTML_PATTERN
);
Matcher
matcher
=
pattern
.
matcher
(
value
);
Matcher
matcher
=
pattern
.
matcher
(
value
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment