From 8d59870d92808a20b3a85d66ae7c45ae7e62ce15 Mon Sep 17 00:00:00 2001 From: Daosheng Mu Date: Tue, 23 Jun 2020 05:44:43 -0700 Subject: [PATCH] Checking Zh-CN code length before looking for a blacklash symbol. (#3531) --- .../vrbrowser/ui/keyboards/ChinesePinyinKeyboard.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ChinesePinyinKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ChinesePinyinKeyboard.java index c5358d8fe..37a6ad515 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ChinesePinyinKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/ChinesePinyinKeyboard.java @@ -147,8 +147,9 @@ public CandidatesResult getCandidates(String aComposingText) { // When using backslashes ({@code \}) in the replacement string // will cause crash at `replaceFirst()`, so we need to replace it first. - if (result.words.get(0).code.charAt(result.words.get(0).code.length() - 1) - == kBackslashCode) { + if (result.words.get(0).code.length() > 0 && + result.words.get(0).code.charAt(result.words.get(0).code.length() - 1) + == kBackslashCode) { newCode = result.words.get(0).code.replace("\\", "\\\\"); aComposingText = aComposingText.replace("\\", "\\\\"); }