Closed Bug 255405 Opened 21 years ago Closed 21 years ago

BinarySearchForPosition can generate invalid unicode for text measurement

Categories

(Core :: Layout: Text and Fonts, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: blizzard, Assigned: blizzard)

References

()

Details

Attachments

(1 file)

BinarySearchForPosition breaks strings into halves for text measurement purposes, but doesn't take into account UTF-16 surrogates when doing so. So from time to time if you're selecting through a string that's built from surrogates, it dumps an unpaired surrogate down to the font layer. Bad behaviour, which prevents selection from working properly. If you have the CODE2000 fonts from the url above and you try to select some of the strings above, it will crash a pango-enabled browser and probably cause pain on others. Patch coming up.
Attached patch patchSplinter Review
This patch makes sure that you never pass down an unpaired high surrogate and also terminates the binary search in the case where the remainder is a surrogate pair. Also, the measurement of the final character can be a surrogate pair as well.
Attachment #155950 - Flags: superreview?(roc)
Attachment #155950 - Flags: review?(roc)
Attachment #155950 - Flags: superreview?(roc)
Attachment #155950 - Flags: superreview+
Attachment #155950 - Flags: review?(roc)
Attachment #155950 - Flags: review+
Checked into the trunk.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: