Skip to content

Fix UTF8Util rejecting valid non-BMP characters, accepting lone surrogates - #318

Merged
popduke merged 2 commits into
apache:mainfrom
pallavithegod:fix-utf8-surrogate-287
Nov 2, 2026
Merged

popduke merged 2 commits into
apache:mainfrom
pallavithegod:fix-utf8-surrogate-287

Conversation

@pallavithegod

Copy link
Copy Markdown
Contributor

Summary

Character.isSurrogatePair is true for valid pairs, but the code treated it as failure: emoji and CJK Extension B+ were rejected while lone surrogates were accepted.

Fix

  • Reject leading low surrogate, trailing high surrogate, and unpaired surrogates in the scan loop.
  • Accept valid surrogate pairs.
  • Update UTF8UtilTest.mustNotChars which asserted the wrong behavior.

Fixes #287

Verification

  • ./mvnw -pl bifromq-util -am test -Dtest=UTF8UtilTest,TopicUtilsTest: 13 tests, 0 failures.

pallavithegod and others added 2 commits October 14, 2026 21:33
…gates

isSurrogatePair returns true for valid pairs, but the code treated
it as failure. Validate unpaired surrogates instead, including
leading low and trailing high surrogates.

Fixes apache#287
@popduke
popduke merged commit ea737ad into apache:main Nov 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] UTF8Util.isWellFormed inverts the surrogate-pair check: valid non-BMP characters are rejected, lone surrogates accepted

2 participants