Skip to content

Keep StringUtils left, right, mid, and overlay off surrogate pair boundaries - #1776

Open
Alwaysgaurav1 wants to merge 1 commit into
apache:masterfrom
Alwaysgaurav1:fix/keep-left-right-mid-off-surrogates
Open

Keep StringUtils left, right, mid, and overlay off surrogate pair boundaries#1776
Alwaysgaurav1 wants to merge 1 commit into
apache:masterfrom
Alwaysgaurav1:fix/keep-left-right-mid-off-surrogates

Conversation

@Alwaysgaurav1

Copy link
Copy Markdown
Contributor

Summary

Prevents StringUtils.left, StringUtils.right, StringUtils.mid, and StringUtils.overlay from splitting UTF-16 surrogate pairs into malformed lone surrogates.

Details of Changes

  • StringUtils.left: Backs off the cut by 1 when splitsSurrogatePair is true to avoid trailing lone high surrogates.
  • StringUtils.right: Advances start by 1 when splitsSurrogatePair is true to avoid leading lone low surrogates.
  • StringUtils.mid: Adjusts start and end boundaries to keep cuts off the middle of surrogate pairs.
  • StringUtils.overlay: Adjusts replacement span boundaries off surrogate pairs.
  • Added comprehensive unit tests in StringUtilsSubstringTest and StringUtilsTest.
  • Added release notes entry in src/changes/changes.xml.

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.

1 participant