bug(web): KMWString deficiencies and bugs
- Dominant language
- Pascal
- Stars
- 534
- Forks
- 143
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 113
Description
Refer to #13726 for lots of details and context, as well as comments within `web/src/engine/common/web-utils/src/kmw-string.ts`. I'll aim to summarize below.
- It was noted that the old BMP-mode handling for `substr` does not properly handle cases where the first parameter is negative and a second parameter is provided.
- See https://github.com/keymanapp/keyman/pull/13726#discussion_r2058066811
- `codePointToCodeUnit` provides negative-value wraparound indexing; `codeUnitToCodePoint` does not.
- See https://github.com/keymanapp/keyman/pull/13726#discussion_r2058519060
- `codePointToCodeUnit` fails to properly handle values that greatly exceed the length of the string, returning `null` instead of a number!pull/13726#discussion_r2058101735
- `indexOf` and `lastIndexOf` do not properly adjust for codepoint-indexing.
- https://github.com/keymanapp/keyman/pull/13726#discussion_r2058552446
- The `slice`, `substr`, and `substring` methods do not adhere to the full specification of the standard String version of these methods when handing edge cases.
- https://github.com/keymanapp/keyman/pull/13726#discussion_r2058674973
- https://github.com/keymanapp/keyman/pull/13726#discussion_r2058683811
- The `prevChar` method does not properly handle negative indices.
- It also has a minor issue with handling negative indices: https://github.com/keymanapp/keyman/pull/13726#discussion_r2058101735
- This one can affect the `codePointToCodeUnit` method when given a negative value for its parameter, which can in turn affect the `substring` and `slice` methods then they're given negative indices.
Fortunately, none of these issues or deficiencies appear to affect our actual use cases within Keyman Engine for Web... for now. There is a risk that issues may arise, though, with the first point about `substr` as probably the riskiest case.
Contributor guide
Assessment
This issue has not been assessed yet.