am 0295a398: am eae7b293: Check the length of the word when add to FusionDictionary.

* commit '0295a39845da87f6f082d50a5c3b1b403f5e07c2':
  Check the length of the word when add to FusionDictionary.
main
Yuichiro Hanada 2012-09-10 17:13:07 -07:00 committed by Android Git Automerger
commit 3cff0dab82
4 changed files with 18 additions and 2 deletions

View File

@ -41,7 +41,7 @@ public class BinaryDictionary extends Dictionary {
* It is necessary to keep it at this value because some languages e.g. German have
* really long words.
*/
public static final int MAX_WORD_LENGTH = 48;
public static final int MAX_WORD_LENGTH = Constants.Dictionary.MAX_WORD_LENGTH;
public static final int MAX_WORDS = 18;
public static final int MAX_SPACES = 16;

View File

@ -128,6 +128,14 @@ public final class Constants {
}
}
public static class Dictionary {
public static final int MAX_WORD_LENGTH = 48;
private Dictionary() {
// This utility class is no publicly instantiable.
}
}
public static final int NOT_A_CODE = -1;
// See {@link KeyboardActionListener.Adapter#isInvalidCoordinate(int)}.

View File

@ -16,6 +16,7 @@
package com.android.inputmethod.latin.makedict;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup;
import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions;
import com.android.inputmethod.latin.makedict.FusionDictionary.Node;
@ -143,7 +144,7 @@ public class BinaryDictInputOutput {
// TODO: Make this value adaptative to content data, store it in the header, and
// use it in the reading code.
private static final int MAX_WORD_LENGTH = 48;
private static final int MAX_WORD_LENGTH = Constants.Dictionary.MAX_WORD_LENGTH;
private static final int MASK_GROUP_ADDRESS_TYPE = 0xC0;
private static final int FLAG_GROUP_ADDRESS_TYPE_NOADDRESS = 0x00;

View File

@ -16,6 +16,8 @@
package com.android.inputmethod.latin.makedict;
import com.android.inputmethod.latin.Constants;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -382,6 +384,11 @@ public class FusionDictionary implements Iterable<Word> {
final ArrayList<WeightedString> shortcutTargets,
final boolean isNotAWord, final boolean isBlacklistEntry) {
assert(frequency >= 0 && frequency <= 255);
if (word.length >= Constants.Dictionary.MAX_WORD_LENGTH) {
MakedictLog.w("Ignoring a word that is too long: word.length = " + word.length);
return;
}
Node currentNode = mRoot;
int charIndex = 0;