Skip to content

Origin.Address.asString(), Strict-Transport-Security and Alt-Svc are formatted with the default Locale (non-ASCII digits)Β #16020

Description

@sharanggupta

Jetty version(s): 12.0.40, 12.1.14 (and jetty-12.0.x / jetty-12.1.x heads)
Jetty Environment: core
Java version/vendor: any JDK 9+ (CLDR locale data); reproduced on OpenJDK 25.0.2
OS type/version: any
Description

A follow-up to #13419 / #13420, which added Locale.ROOT to the %f and DecimalFormat sites. Three
String.format("%d") sites still follow the JVM's default Locale, and on a JVM whose default Locale uses
native digits (for example ar-EG, fa-IR, bn-BD, ne-NP) they produce strings that are not valid on
the wire:

  1. jetty-core/jetty-client/.../Origin.java β€” Origin.Address.asString() returns
    String.format("%s:%d", host, port). HttpProxy uses it as the CONNECT request target and the
    Host header sent to a forward proxy.
  2. jetty-core/jetty-server/.../SecureRequestCustomizer.java β€” formatSTS() builds
    String.format("max-age=%d%s", ...); the resulting Strict-Transport-Security: max-age=Ω£Ω‘Ω₯Ω£Ω¦Ω Ω Ω 
    is silently ignored by browsers, so HSTS is not enforced.
  3. jetty-core/jetty-http2/jetty-http2-server/.../HTTP2ServerConnectionFactory.java (12.1.x only) β€”
    the Alt-Svc header is built with String.format("h3=\":%d\"", port) and String.format("; ma=%d", ...).

The project's surefire configuration pins -Duser.language=en -Duser.region=US, which is why the test
suite never sees it.

How to reproduce?

Against the released 12.1.14 jars (jetty-client, jetty-server and their dependencies):

// java -Duser.language=ar -Duser.country=EG ...
new Origin.Address("example.com", 443).asString();      // example.com:Ω€Ω€Ω£
SecureRequestCustomizer c = new SecureRequestCustomizer();
c.setStsMaxAge(31536000);                                 // Strict-Transport-Security: max-age=Ω£Ω‘Ω₯Ω£Ω¦Ω Ω Ω 

I have a branch that replaces the three formats with plain concatenation (the values are a String and
an int/long, so no formatting is needed) and adds OriginTest and SecureRequestCustomizerTest
that switch the default Locale to ar-EG around the calls; happy to open it as a PR against
jetty-12.0.x (sites 1 and 2) with the Alt-Svc site for jetty-12.1.x.

Activity

  1. self-assigned this
    on Oct 23, 2026
  2. added
    BugFor general bugs on Jetty side
    on Oct 23, 2026
  3. moved this to πŸ‘€ In review in Jetty 12.1.15 - FROZENon Oct 23, 2026
  4. moved this from πŸ‘€ In review to πŸ— In progress in Jetty 12.1.15 - FROZENon Oct 23, 2026
  5. lorban commented on Oct 23, 2026

    @lorban
    Contributor

    Thanks for reporting this. I've created a PR with the 12.1.x candidate fix: #16025

  6. added 2 commits that reference this issue on Oct 23, 2026
  7. added a commit that references this issue on Oct 26, 2026
  8. moved this from πŸ— In progress to βœ… Done in Jetty 12.1.15 - FROZENon Oct 26, 2026
  9. added a commit that references this issue on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugFor general bugs on Jetty side

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions