Skip to content

make from_chars(double) parsing locale-independent#2475

Closed
metsw24-max wants to merge 1 commit into
yhirose:masterfrom
metsw24-max:from-chars-double-locale
Closed

make from_chars(double) parsing locale-independent#2475
metsw24-max wants to merge 1 commit into
yhirose:masterfrom
metsw24-max:from-chars-double-locale

Conversation

@metsw24-max

Copy link
Copy Markdown
Contributor

Locale-dependent quality value parsing

detail::from_chars(double) hands off to std::strtod, which reads the decimal point from the global C locale, whereas the integer overload beside it is written to stay locale-independent. Once an embedding process has run setlocale(LC_ALL, "") into a locale that uses ',' (de, fr and others), an untrusted Accept/Accept-Encoding header such as gzip;q=0.8 is parsed as q=0 because strtod stops at the '.', so the weight collapses to "not acceptable" and the server quietly drops gzip and skews content negotiation. The fix translates '.' to the active locale's separator before the call, restoring the locale-independent intent without pulling in a different parser. The regression test pins q-value ordering under a comma-decimal locale and skips where none is installed.

@yhirose yhirose closed this in 7307c41 Jun 18, 2026
@yhirose

yhirose commented Jun 18, 2026

Copy link
Copy Markdown
Owner

@metsw24-max thanks for the pull request! I implemented it in a better way.

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.

2 participants