Fix flattening crash from %0$s in translatable components - #14164
Closed
chirag-gamer wants to merge 1 commit into
Closed
Fix flattening crash from %0$s in translatable components#14164chirag-gamer wants to merge 1 commit into
chirag-gamer wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The translatable component flattener computed the argument index as
Integer.parseInt(argIdx) - 1, so%0$syields -1. The guard only checkedidx < args.size(), and -1 passes that whenever the component has arguments, soargs.get(-1)threwIndexOutOfBoundsExceptioninstead of dropping the placeholder like out-of-range positive indices are dropped.Fixes #14163
The guard is now
idx >= 0 && idx < args.size(), matching the existing "drop out-of-range placeholder" behavior. The sequential-argument branch (argPosition++) already only produced non-negative indices, so this only changes the%0$scase.I reproduced the crash with a small harness (parse
%0$s,idx = -1,args.get(-1)throws) and confirmed the fix compiles against the full server. I couldn't add a JUnit regression test for the full flattening path because it needs a language entry whose value actually contains%0$s, which isn't in the shipped translations. Happy to add one if there's a way to inject test language data.