Skip to content

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

Open
pallavithegod wants to merge 1 commit into
apache:mainfrom
pallavithegod:fix-utf8-surrogate-287
Open

pallavithegod wants to merge 1 commit into
apache:mainfrom
pallavithegod:fix-utf8-surrogate-287

Conversation

@pallavithegod

Copy link
Copy Markdown

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.

…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
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

1 participant