kdelay opened a new pull request, #1758:
URL: https://github.com/apache/commons-lang/pull/1758

   Repro: with U+1F600 GRINNING FACE (a surrogate pair) as `EMOJI`, 
`StringUtils.abbreviateMiddle("a" + EMOJI + EMOJI + "b", ".", 4)` returns `a` 
plus a lone high surrogate before the middle, and 
`StringUtils.abbreviateMiddle(EMOJI + "abc" + EMOJI, "..", 5)` returns a lone 
low surrogate after the middle.
   Cause: the head and tail cut offsets are computed in `char` units and sliced 
with `String.substring`, so a cut that lands between the two halves of a 
surrogate pair leaves an unpaired surrogate in the result. #1719 fixed the same 
defect in `abbreviate` and `truncate`, but the sibling `abbreviateMiddle` was 
left out.
   Fix: reuse the `splitsSurrogatePair` helper introduced by #1719 to nudge 
each cut to the nearest code-point edge before slicing, so a pair is never 
split. The result still never exceeds `length`, and cuts that already sit 
between whole code points are unchanged. The new test fails on the current code 
and passes with the fix.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to