On Mon, 8 Jun 2026 20:55:00 GMT, Justin Lu <[email protected]> wrote:

> ListFormat validates patterns before passing them to MessageFormat, but it 
> currently allows single quotes as is. MessageFormat interprets these as 
> escaping syntax, which can lead to incorrect output. For example, given the 
> end pattern  `"{0}'{1}'"` and an empty two pattern, a `ListFormat` formats 
> `List.of("foo", "bar")` as `"foo{1}"` instead of `"foo'bar'"`.
> 
> This behavior violates the specification, as ListFormat does not define any 
> escaping mechanisms. This PR converts ListFormat patterns to the 
> corresponding MessageFormat pattern by ensuring all single quotes are 
> doubled, such that they are always treated literally by the MessageFormat. I 
> intentionally handle the replacement logic at the MessageFormat creation site 
> instead of the existing ListFormat validation, because the patterns should 
> remain exactly the same as the input given by the user.
> 
> I am treating this as a normal bug fix since the current behavior violates 
> the specification and is incorrect. No one should be relying on this type of 
> behavior. However, I can file a CSR if deemed necessary.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Thanks for the review!

-------------

PR Comment: https://git.openjdk.org/jdk/pull/31430#issuecomment-4661807308

Reply via email to