-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ExceptionHandler 中 Exception 部分返回 body 参数增加 html 转义 #10643
Conversation
@ExceptionHandler(IllegalArgumentException.class) | ||
private ResponseEntity<String> handleIllegalArgumentException(IllegalArgumentException e) { | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(ExceptionUtil.getAllExceptionMsg(e)); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't change the indent. Use nacos code style to reformat codes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handled
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #10643 +/- ##
==========================================
Coverage 53.60% 53.60%
- Complexity 5516 5517 +1
==========================================
Files 897 897
Lines 28811 28812 +1
Branches 3161 3161
==========================================
+ Hits 15444 15445 +1
- Misses 12018 12019 +1
+ Partials 1349 1348 -1
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
} | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(ExceptionUtil.getAllExceptionMsg(e)); | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) | ||
.body(HtmlUtils.htmlEscape(ExceptionUtil.getAllExceptionMsg(e), "utf-8")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why directly set utf-8?
* ExceptionHandler 中 Exception 部分返回 body 参数增加 html 转义 * 根据 nacos code style 重新格式化该文件
relation #10640
Please do not create a Pull Request without creating an issue first.
What is the purpose of the change
在 ExceptionHandler 中,返回的数据如果存在 html 标签,则可能导致前端出现一些特殊情况,所以对于未知的 Exception 返回 body 部分增加 html 转义
Brief changelog
XX
Verifying this change
XXXX
Follow this checklist to help us incorporate your contribution quickly and easily:
[ISSUE #123] Fix UnknownException when host config not exist
. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true
to make sure basic checks pass. Runmvn clean install -DskipITs
to make sure unit-test pass. Runmvn clean test-compile failsafe:integration-test
to make sure integration-test pass.