Skip to content

stop ExtendedMessageFormat seekNonWs reading past the pattern end#759

Open
dxbjavid wants to merge 1 commit into
apache:masterfrom
dxbjavid:seeknonws-bounds
Open

stop ExtendedMessageFormat seekNonWs reading past the pattern end#759
dxbjavid wants to merge 1 commit into
apache:masterfrom
dxbjavid:seeknonws-bounds

Conversation

@dxbjavid

@dxbjavid dxbjavid commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

The registry-based ExtendedMessageFormat constructor parses its pattern with seekNonWs, which asks the split matcher about the character at the current parse index without first checking it is still inside the buffer. A truncated format element such as {, {0, or trailing text like {0}extra{ leaves the parse position at the end of the pattern, so the matcher reads one past the char array and the constructor throws ArrayIndexOutOfBoundsException rather than the documented IllegalArgumentException that the plain constructor already gives for the same input. This bounds the seek to the pattern length so those patterns report the usual unterminated-format-element error; a regression test covers the three shapes above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant