Skip to content

Do not decode numeric references to surrogates in HtmlUtils.htmlUnescape - #37721

Open
Marti2203 wants to merge 1 commit into
spring-projects:mainfrom
Marti2203:html-unescape-surrogate
Open

Marti2203 wants to merge 1 commit into
spring-projects:mainfrom
Marti2203:html-unescape-surrogate

Conversation

@Marti2203

Copy link
Copy Markdown

HtmlCharacterEntityDecoder leaves numeric character references beyond Character.MAX_CODE_POINT undecoded, but decodes references to surrogate code points (U+D800 to U+DFFF), which are not characters: HtmlUtils.htmlUnescape("x�y") returns "x\uD800y", a string with a lone high surrogate, which turns into ? once encoded, for instance as UTF-8.

This change leaves such references undecoded, as is done for out-of-range values. A new test, HtmlUtilsTests.htmlUnescapeLeavesSurrogateReferencesUnchanged, checks � and � and the neighbouring ퟿ and , which are still decoded; it fails before the change and passes after it.

Testing: HtmlUtilsTests and HtmlCharacterEntityReferencesTests, :spring-web:checkstyleMain and checkstyleTest pass. 7.0.x and 6.2.x have the same code.

The issue was found by an LLM-assisted tool and verified manually.

HtmlCharacterEntityDecoder leaves numeric character references beyond
Character.MAX_CODE_POINT undecoded, but decodes references to surrogate
code points (U+D800 to U+DFFF), which are not characters: "�"
becomes a lone high surrogate, i.e. an invalid UTF-16 string that turns
into "?" once encoded, for instance as UTF-8.

Leave such references undecoded, as is done for out-of-range values.

Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 18, 2026
@bclozel

bclozel commented Nov 18, 2026

Copy link
Copy Markdown
Member

Hi @Marti2203, and thanks for your interest in Spring Framework.

You've opened more than a dozen PRs in the last 24 hours, and we can't review them at that pace. Each one needs a maintainer to read it, understand the context, and take responsibility for merging it.

AI-assisted contributions are fine, but you're accountable for what you submit. You should understand each change, have run the build and tests, and be able to defend your choices in review. A large batch of PRs makes that hard and pushes the review work onto us.

Please keep to a few open PRs at a time, and focus on changes that matter, like real bugs or improvements that are important to your projects. We'll review a few of these and might close the rest.

Thanks for understanding.

@Marti2203

Copy link
Copy Markdown
Author

Hi @bclozel , sorry if it looked like spam. I will keep the open amount to 5. I fully understand the accountability aspect and am ready to discuss.

@Marti2203

Copy link
Copy Markdown
Author

Will keep the current 13, but not add anything more. Really sorry if I made a bad impression 😓

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants