fix(libSceHttp): escape URI bytes independently of host locale #4963

Closed
QRMOE wants to merge 3 commits from upstream-pr/4963 into main
QRMOE commented 2026-10-13 06:39:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by QRMOE on 2026-10-13T06:39:16Z.


What

Use the ASCII URI unreserved alphabet in sceHttpUriEscape, independently of the host's character locale. Main uses std::isalnum, so selecting German_Germany.1252 makes it leave some bytes above 0x7f unescaped and report too small a required output size. For the byte string caf\xE9 \xC3\xA9, the required output is caf%E9%20%C3%A9 (16 bytes including NUL); main reports 12 bytes in that locale.

The alphabet follows RFC 3986 section 2.3 and matches shadPS4's sceHttpUriEscape. Console behavior has not been measured and is recorded in technical debt.

Tested

Windows, MinGW GCC 15.2, Release, BUILD_TESTING=ON, main base ea2bbefb2:

  • The new regression fails on unchanged main: URI escaping changed with the host locale: required 12.
  • All byte values 0..255 are checked against the explicit unreserved alphabet, including empty input, output-size queries, exact-fit buffers, trailing sentinels and undersized buffers left untouched. Windows repeats the checks under the native German_Germany.1252 locale and restores the original character locale afterward. The all-byte checks also run on other platforms.
  • Explicit libs build and HTTP, HTTP response-header parsing, HTTP2, SSL and patched-library loading tests passed (5/5). Conventions and whitespace checks passed.
  • A full Windows build was attempted. All remaining components built, but Windows denied recreation of eight unrelated test outputs (guest_sce_net, guest_poll, guest_socket_read_write, guest_tcp, guest_socket_pair, guest_dup, guest_socket_events and guest_fstatfs). Avast's log records automatic sandboxing of the test programs. The local full-build limitation remains; local full-build success is not claimed.
  • No title playback, network request or console measurement was performed.

Review validation

  • nicolasfalesy's Linux report: Linux HTTP checks passed in a combined merge; reverting this fix still passed on that host, as its locale did not reproduce the Windows issue.
  • xXPBSXx's Windows report: Reports a clean merge, full Windows build with 0 errors, relevant runtime checks and conventions passing.

Ready for maintainer review. Full Linux/Windows CI requires a maintainer's manual dispatch; marking this PR ready does not claim those jobs passed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4839402801 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4963). Originally posted by [QRMOE](https://github.com/QRMOE) on 2026-10-13T06:39:16Z. --- ### What Use the ASCII URI unreserved alphabet in `sceHttpUriEscape`, independently of the host's character locale. Main uses `std::isalnum`, so selecting `German_Germany.1252` makes it leave some bytes above 0x7f unescaped and report too small a required output size. For the byte string `caf\xE9 \xC3\xA9`, the required output is `caf%E9%20%C3%A9` (16 bytes including NUL); main reports 12 bytes in that locale. The alphabet follows [RFC 3986 section 2.3](https://www.rfc-editor.org/rfc/rfc3986#section-2.3) and matches [shadPS4's `sceHttpUriEscape`](https://github.com/shadps4-emu/shadPS4/blob/main/src/core/libraries/network/http.cpp#L3424-L3427). Console behavior has not been measured and is recorded in technical debt. ### Tested Windows, MinGW GCC 15.2, Release, `BUILD_TESTING=ON`, main base `ea2bbefb2`: - The new regression fails on unchanged main: `URI escaping changed with the host locale: required 12`. - All byte values 0..255 are checked against the explicit unreserved alphabet, including empty input, output-size queries, exact-fit buffers, trailing sentinels and undersized buffers left untouched. Windows repeats the checks under the native `German_Germany.1252` locale and restores the original character locale afterward. The all-byte checks also run on other platforms. - Explicit libs build and HTTP, HTTP response-header parsing, HTTP2, SSL and patched-library loading tests passed (5/5). Conventions and whitespace checks passed. - A full Windows build was attempted. All remaining components built, but Windows denied recreation of eight unrelated test outputs (`guest_sce_net`, `guest_poll`, `guest_socket_read_write`, `guest_tcp`, `guest_socket_pair`, `guest_dup`, `guest_socket_events` and `guest_fstatfs`). Avast's log records automatic sandboxing of the test programs. The local full-build limitation remains; local full-build success is not claimed. - No title playback, network request or console measurement was performed. ### Review validation - [nicolasfalesy's Linux report](https://github.com/boykopovar/AnyPS5/pull/4963#issuecomment-6140476955): Linux HTTP checks passed in a combined merge; reverting this fix still passed on that host, as its locale did not reproduce the Windows issue. - [xXPBSXx's Windows report](https://github.com/boykopovar/AnyPS5/pull/4963#issuecomment-6141720384): Reports a clean merge, full Windows build with 0 errors, relevant runtime checks and conventions passing. Ready for maintainer review. Full Linux/Windows CI requires a maintainer's manual dispatch; marking this PR ready does not claim those jobs passed. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes
nicolasfalesy commented 2026-10-13 07:22:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T07:22:32Z.


Linux test (Arch, GCC 16.2.1, glibc, Release, LANG=en_US.UTF-8), this PR merged onto main 7e181fcc3 together with #4963, #4953, #4946 and #4942 (no conflicts): guest_http, guest_http_response_header and guest_http2 pass. With Uri.cpp put back to main's version, guest_http still passes on Linux, so the locale dependence this fixes does not show up on this Linux host; the change is harmless there.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6140476955 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4963#issuecomment-6140476955). Originally posted by [nicolasfalesy](https://github.com/nicolasfalesy) on 2026-10-13T07:22:32Z. --- Linux test (Arch, GCC 16.2.1, glibc, Release, LANG=en_US.UTF-8), this PR merged onto `main` 7e181fcc3 together with #4963, #4953, #4946 and #4942 (no conflicts): `guest_http`, `guest_http_response_header` and `guest_http2` pass. With `Uri.cpp` put back to `main`'s version, `guest_http` still passes on Linux, so the locale dependence this fixes does not show up on this Linux host; the change is harmless there.
xXPBSXx commented 2026-10-13 08:41:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T08:41:04Z.


Windows test: head 669731323 merged onto current main c2565f014 (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, -j2: full build 0 errors; ctest with the filter guest_http: guest_http passed, guest_http_response_header passed, guest_http2 passed (3 test(s), 0 failed); python tools/check_conventions.py --base upstream/main passed. I did not run the new tests against main without the change.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6141720384 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4963#issuecomment-6141720384). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T08:41:04Z. --- Windows test: head `669731323` merged onto current `main` `c2565f014` (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, `-j2`: full build 0 errors; ctest with the filter `guest_http`: guest_http passed, guest_http_response_header passed, guest_http2 passed (3 test(s), 0 failed); `python tools/check_conventions.py --base upstream/main` passed. I did not run the new tests against `main` without the change. AI-assisted (Claude Code).
oneandonlydean commented 2026-10-14 02:35:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:35:12Z.


Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159614025 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4963#issuecomment-6159614025). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:35:12Z. --- Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
QRMOE commented 2026-10-15 07:46:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by QRMOE on 2026-10-15T07:46:07Z.


Understood. I’ll leave this closed and revisit it only with a title ID and a current-main log showing the failure. I’ll hold off on new PRs without a title needing the change while the queue is high.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6187156707 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4963#issuecomment-6187156707). Originally posted by [QRMOE](https://github.com/QRMOE) on 2026-10-15T07:46:07Z. --- Understood. I’ll leave this closed and revisit it only with a title ID and a current-main log showing the failure. I’ll hold off on new PRs without a title needing the change while the queue is high.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!4963
No description provided.