Check length of words for personalization dict.

Bug: 12602903

Change-Id: I1ea4e558b6d2fde425ce28226647ad60095e3488
main
Keisuke Kuroyanagi 2014-01-24 16:32:28 -08:00
parent c894071b2d
commit b7197b705b
1 changed files with 5 additions and 1 deletions

View File

@ -26,6 +26,7 @@ import android.util.Log;
import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.AssetFileAddress; import com.android.inputmethod.latin.AssetFileAddress;
import com.android.inputmethod.latin.BinaryDictionaryGetter; import com.android.inputmethod.latin.BinaryDictionaryGetter;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.makedict.BinaryDictIOUtils; import com.android.inputmethod.latin.makedict.BinaryDictIOUtils;
import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader; import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader;
@ -368,11 +369,14 @@ public class DictionaryInfoUtils {
return dictList; return dictList;
} }
@UsedForTesting
public static boolean looksValidForDictionaryInsertion(final CharSequence text, public static boolean looksValidForDictionaryInsertion(final CharSequence text,
final SpacingAndPunctuations spacingAndPunctuations) { final SpacingAndPunctuations spacingAndPunctuations) {
if (TextUtils.isEmpty(text)) return false; if (TextUtils.isEmpty(text)) return false;
final int length = text.length(); final int length = text.length();
// TODO: Make this test "length > Constants.DICTIONARY_MAX_WORD_LENGTH".
if (length >= Constants.DICTIONARY_MAX_WORD_LENGTH) {
return false;
}
int i = 0; int i = 0;
int digitCount = 0; int digitCount = 0;
while (i < length) { while (i < length) {