keymanapp / keymanapp/keyman

bug(android): performLeftDeletions triggering StringIndexOutOfBoundsException

Open
#15,612 1 comment 0 reactions 1 assignee Claimed by @jahorton View on GitHub
android/ bug
Dominant language
Pascal
Stars
534
Forks
143
Avg merge
2d 10h
Merged PRs (30d)
113

Description

Sentry Issue: [KEYMAN-ANDROID-7A3](https://keyman.sentry.io/issues/6781744657/?referrer=github_integration)

```
StringIndexOutOfBoundsException: begin 0, end -1, length 1
at com.keyman.engine.KMKeyboardJSHandler.performLeftDeletions(KMKeyboardJSHandler.java:346)
at com.keyman.engine.KMKeyboardJSHandler.-$$Nest$smperformLeftDeletions
at com.keyman.engine.KMKeyboardJSHandler$1.run(KMKeyboardJSHandler.java:219)
...
(9 additional frame(s) were not displayed)
```

I'm not seeing keyboard details to trigger this.
Conceptually, it seems like given a context of 1 character, and attempting to do 2 left deletions we then get to:
```
int start = 0;
int end = 1-(2+0) = -1;
CharSequence expectedChars;
try {
expectedChars = charsBackup.subSequence(start, end);
```

which throws because of a negative index.

https://github.com/keymanapp/keyman/blob/bc546d004c0b03fb7a3e798cb1e71f9c2b5166a9/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboardJSHandler.java#L340-L346

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.