[Webkit-unassigned] [Bug 231606] ASSERT hit in surrogatePairAwareIndex and surrogatePairAwareStart lambdas for text with unpaired surrogates
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Oct 12 18:07:21 PDT 2021
https://bugs.webkit.org/show_bug.cgi?id=231606
--- Comment #16 from Gabriel Nava Marino <gnavamarino at apple.com> ---
(In reply to Darin Adler from comment #15)
> Comment on attachment 440982 [details]
> Patch
>
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=440982&action=review
>
> >>>> Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp:155
> >>>>
> >>>
> >>> It would be:
> >>>
> >>> auto right = std::min<unsigned>(left + offset, (startPosition + length - 1));
> >>> U16_SET_CP_LIMIT(text, 0, right, text.length());
> >>>
> >>> auto middle = surrogatePairAwareIndex((left + right) / 2);
> >>> U16_SET_CP_LIMIT(text, 0, middle, text.length());
> >>
> >> Thank you, I will try this! Although I just notice that currently, surrogatePairAwareIndex returns the index at trail whereas U16_SET_CP_LIMIT returns the index past it:
> >>
> >> #define U16_SET_CP_LIMIT(s, start, i, length) UPRV_BLOCK_MACRO_BEGIN { \
> >> if((start)<(i) && ((i)<(length) || (length)<0) && U16_IS_LEAD((s)[(i)-1]) && U16_IS_TRAIL((s)[i])) { \
> >> ++(i); \
> >> } \
> >> } UPRV_BLOCK_MACRO_END
> >
> > Oh, OK, good point. So my code is wrong. It would be more like this:
> >
> > auto right = std::min<unsigned>(left + offset + 1, startPosition + length);
> > U16_SET_CP_LIMIT(text, 0, right, text.length());
> > --right;
>
> And perhaps then could change the logic to get rid of the need for the
> "--right".
I will work to update the logic to avoid the extra decrement. Thank you for the suggestion Darin.
>
> Maybe a waste of time, but I do think that using the U16 macros is still a
> little easier to get correct than writing our own code.
Yes, agreed! I will work to get this macro working. The upside being that the "safe" macro offers handling of unpaired surrogates and checks for string boundaries.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20211013/fcd859e0/attachment.htm>
More information about the webkit-unassigned
mailing list