Validate spell checker suggestions before applying.
Fix: 185786752 Test: atest CtsInputMethodTestCases:SpellCheckerTest Change-Id: Icf447fc3ab174bc17af0e823b830f5abef6071df
This commit is contained in:
@@ -461,7 +461,7 @@ public class SpellChecker implements SpellCheckerSessionListener {
|
||||
@Override
|
||||
public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results) {
|
||||
final Editable editable = (Editable) mTextView.getText();
|
||||
|
||||
final int sentenceLength = editable.length();
|
||||
for (int i = 0; i < results.length; ++i) {
|
||||
final SentenceSuggestionsInfo ssi = results[i];
|
||||
if (ssi == null) {
|
||||
@@ -475,6 +475,9 @@ public class SpellChecker implements SpellCheckerSessionListener {
|
||||
}
|
||||
final int offset = ssi.getOffsetAt(j);
|
||||
final int length = ssi.getLengthAt(j);
|
||||
if (offset < 0 || offset + length > sentenceLength) {
|
||||
continue;
|
||||
}
|
||||
final SpellCheckSpan scs = onGetSuggestionsInternal(
|
||||
suggestionsInfo, offset, length);
|
||||
if (spellCheckSpan == null && scs != null) {
|
||||
|
||||
Reference in New Issue
Block a user