donnerpeter commented on a change in pull request #2238: URL: https://github.com/apache/lucene-solr/pull/2238#discussion_r563673451
########## File path: lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java ########## @@ -1299,7 +1314,12 @@ void appendFlag(char flag, StringBuilder to) { if (replacement.isEmpty()) { continue; } - flags[upto++] = (char) Integer.parseInt(replacement); + int flag = Integer.parseInt(replacement); + if (flag == 0 || flag >= Character.MAX_VALUE) { // read default flags as well + throw new IllegalArgumentException( Review comment: `ParseException` needs some `errorOffset` obligatorily (which is dubiously filled here with the current line number), and it's not available in this method, and not all callers have anything meaningful to pass there. For consistency, we could replace `ParseException` with something less choosy :) ########## File path: lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java ########## @@ -1310,10 +1330,8 @@ void appendFlag(char flag, StringBuilder to) { @Override void appendFlag(char flag, StringBuilder to) { Review comment: Yes, that's `some tests failed after implementing step 1 and were fixed in step 2`. However nice it seemed, it was wrong, because other flags were appended after this one without any comma. Trailing commas are no problem, as empty flags are skipped in the previous method. ########## File path: lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Stemmer.java ########## @@ -588,7 +577,7 @@ private boolean checkCondition( } private boolean isFlagAppendedByAffix(int affixId, char flag) { - if (affixId < 0) return false; + if (affixId < 0 || flag == 0) return false; Review comment: A good idea, thanks! ########## File path: lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java ########## @@ -1310,10 +1330,8 @@ void appendFlag(char flag, StringBuilder to) { @Override void appendFlag(char flag, StringBuilder to) { Review comment: Yes. Currently it's just one place which definitely appends no flags before this one, and may append some flags after this, so the implementation is tied to that. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org