CFString: fix range in CFStringGetSurrogatePairForLongCharacter#59
Open
DTW-Thalion wants to merge 1 commit into
Open
CFString: fix range in CFStringGetSurrogatePairForLongCharacter#59DTW-Thalion wants to merge 1 commit into
DTW-Thalion wants to merge 1 commit into
Conversation
The function rejected characters greater than U+10000 (returning false) and produced a surrogate pair for everything up to and including U+10000, including BMP characters. The comparison was inverted: a surrogate pair is needed for supplementary-plane characters (>= U+10000), while BMP characters (< U+10000) need none, so nearly the whole supplementary plane (U+10001..U+10FFFF) was wrongly rejected. Use "character < 0x10000". Add Tests/CFString/surrogate.m.
02eb6bd to
fcf7ff4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CFStringGetSurrogatePairForLongCharacterhad an inverted range test:A UTF-16 surrogate pair is needed for supplementary-plane characters
(
>= U+10000); BMP characters (< U+10000) need none. The old check rejectedalmost the entire supplementary plane (U+10001..U+10FFFF) and, conversely,
produced a bogus surrogate pair for BMP characters (and exactly U+10000 was
the only value handled correctly).
Fix
if (character < 0x10000) return false;Test
Tests/CFString/surrogate.m: U+1F600 yieldsD83D DE00and round-trips,U+10000 yields a pair, and a BMP character (U+0041) yields none.