fix(ui): rank Accept-Language tags by q-value instead of substring scan - #2084
fix(ui): rank Accept-Language tags by q-value instead of substring scan#2084AmirF194 wants to merge 1 commit into
Conversation
detect_ui_lang() (src/ui/http_server.c) picked the UI language with strstr(accept_language, "zh"), so any Chinese tag anywhere in the header served the Chinese UI regardless of position or q-value. A bilingual header whose top preference is English (e.g. en-US;q=0.9,zh;q=0.5) still got Chinese. Per RFC 9110 12.5.4, parse each tag's q-value (default 1.0), treat q=0 as explicitly unacceptable (12.5.1), and return the highest-ranked tag whose base language is zh or en, keeping the first occurrence on a tie. This mirrors the UI bundle's own JT() fallback parser, quoted in the issue, which already implements this correctly as a client-side fallback. Fixes DeusData#1829 Signed-off-by: Amir Fathi <amirfathi.me@gmail.com>
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
|
Thank you for contributing the Accept-Language quality-value handling and HTTP-server tests. This is queued as a UI behavior fix. We need more time to review the parsing and fallback cases before giving a decision. The review queue is currently full, so detailed feedback may take a little time. We are working through it carefully and appreciate the work you have put into supporting the project. Thank you for your patience. |
What does this PR do?
detect_ui_lang()(src/ui/http_server.c) picks the/api/ui-configlanguage withstrstr(accept_language, "zh"), so any Chinese tag anywhere in the header serves the Chinese UI, regardless of position or q-value. A bilingual browser list whose top preference is English (en-US;q=0.9,zh;q=0.5) still gets Chinese.Per RFC 9110 12.5.4, the fix parses each tag's q-value (default 1.0), treats
q=0as explicitly unacceptable (12.5.1), and returns the highest-ranked tag whose base language iszhoren, keeping the first occurrence on a tie. This mirrors the UI bundle's ownJT()fallback parser (quoted in the issue), which already does this correctly as a client-side fallback when the endpoint is unreachable.Checklist
git commit -s)scripts/test.sh --suites httpd)Verification
"lang":"en"and get"lang":"zh"on plainmain; both pass on this branch. Ran both ways in a cleanubuntu:24.04container. Fullhttpdsuite: 66 passed, 1 skipped (pre-existing, Windows-only) on both sides.detect_ui_langhas a single call site (handle_ui_config); no other reader needed updating.cppcheckandclang-format --dry-runon the two changed files: same output before and after this change, so nothing new here.Fixes #1829