File tree Expand file tree Collapse file tree
src/main/java/org/apache/commons/codec/language Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,13 +126,28 @@ public final String encode(String name) {
126126 // Preprocessing
127127 name = cleanName (name );
128128
129+ // Bulletproof if name becomes empty after cleanName(name)
130+ if (EMPTY .equalsIgnoreCase (name ) || SPACE .equalsIgnoreCase (name ) || name .length () == 0 ) {
131+ return EMPTY ;
132+ }
133+
129134 // BEGIN: Actual encoding part of the algorithm...
130135 // 1. Delete all vowels unless the vowel begins the word
131136 name = removeVowels (name );
132137
138+ // Bulletproof if name becomes empty after removeVowels(name)
139+ if (EMPTY .equalsIgnoreCase (name ) || SPACE .equalsIgnoreCase (name ) || name .length () == 0 ) {
140+ return EMPTY ;
141+ }
142+
133143 // 2. Remove second consonant from any double consonant
134144 name = removeDoubleConsonants (name );
135145
146+ // Bulletproof if name becomes empty after removeDoubleConsonants(name)
147+ if (EMPTY .equalsIgnoreCase (name ) || SPACE .equalsIgnoreCase (name ) || name .length () == 0 ) {
148+ return EMPTY ;
149+ }
150+
136151 // 3. Reduce codex to 6 letters by joining the first 3 and last 3 letters
137152 name = getFirst3Last3 (name );
138153
You can’t perform that action at this time.
0 commit comments