alhudz opened a new pull request, #1744:
URL: https://github.com/apache/commons-lang/pull/1744

   `ExtendedMessageFormat.parseFormatDescription` walks a format element's 
style with a `for` loop whose update clause always calls `next(pos)`, but the 
`QUOTE` branch hands off to `getQuotedString`, which already leaves `pos` one 
past the closing quote. The loop then advances a second time and skips the 
character right after that quote, so when a style ends with a quoted literal 
the terminating `}` is never seen: `depth` never returns to `0`, the loop runs 
off the end, and the constructor throws `IllegalArgumentException: Unterminated 
format element`. This only happens on the registry path, so `new 
ExtendedMessageFormat("{0,number,0'%'}", registry)` throws even though 
`java.text.MessageFormat` and `ExtendedMessageFormat` without a registry both 
parse that pattern to `5%`.
   
   The fix switches the loop to the `while` form the two sibling parsers in 
this class already use (`applyPattern`, `insertFormats`): advance one position 
per non-quote branch and let the `QUOTE` branch's `getQuotedString` do its own 
advance. Leaving the position arithmetic to the single loop that consumes the 
quoted run is what stops the double count. The added test fails before the 
change with the `Unterminated format element` exception and passes after.


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to