Media: refuse a network share after file://localhost too (///server, /%5Cserver, /\\server) #257

Open
sharan104 wants to merge 1 commit from upstream-pr/257 into main
sharan104 commented 2026-11-26 13:31:30 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by sharan104 on 2026-11-26T13:31:30Z.


The media source resolver's local-files rule (media.rs, local()) lets any file: URL that names this machine through as a local file. That's because file://localhost//movies is \movies to the host. But the host drops only one of two leading separators after the host name, so these three spellings all reach the host's resolver unchanged, past modules::net:

  • file://localhost///server/share/a.mp4
  • file://localhost/%5Cserver/share/a.mp4
  • file://localhost/\\server/share/a.mp4

They all mean \\server\share\a.mp4.

I checked this with Media Foundation on Windows 11. file://localhost///127.0.0.1/C$/Windows/Media/chimes.wav opens a file through the admin share (S_OK). An unknown server fails with ERROR_BAD_NETPATH, which shows it was treated as a network path. So a title, or a video URL inside its data, could make us open files on network shares, the exact thing this rule is there to refuse.

The gap came from fc0d5e7, which deliberately exempted URLs naming this machine.

Fix: after a host name, one of two leading separators is dropped before the share check, as the host does. The share check now runs whether or not a host is named. file://localhost//server/share and its backslash spelling still pass as local paths (\server\share), as before.

Tests:

  • The three spellings are added to SHARE_URLS. shares_are_refused_however_they_are_spelled fails without the fix (left: Ok("file://localhost///server/share/a.mp4")) and passes with it.
  • the_host_reads_those_spellings_as_shares confirms Media Foundation reads each new spelling as a share.
  • One more local spelling is added to the cases that must still pass.

Results:

  • cargo test -p victory-hle --locked: 155 passed, 0 failed, 2 ignored. The media tests passed 10 out of 10 runs.
  • cargo clippy -p victory-hle --all-targets --locked --no-deps -- -D warnings is clean, with and without --all-features.

🤖 Generated with Claude Code

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6627745086 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/257). Originally posted by [sharan104](https://github.com/sharan104) on 2026-11-26T13:31:30Z. --- The media source resolver's local-files rule (`media.rs`, `local()`) lets any `file:` URL that names this machine through as a local file. That's because `file://localhost//movies` is `\movies` to the host. But the host drops only **one** of two leading separators after the host name, so these three spellings all reach the host's resolver unchanged, past `modules::net`: - `file://localhost///server/share/a.mp4` - `file://localhost/%5Cserver/share/a.mp4` - `file://localhost/\\server/share/a.mp4` They all mean `\\server\share\a.mp4`. I checked this with Media Foundation on Windows 11. `file://localhost///127.0.0.1/C$/Windows/Media/chimes.wav` opens a file through the admin share (S_OK). An unknown server fails with `ERROR_BAD_NETPATH`, which shows it was treated as a network path. So a title, or a video URL inside its data, could make us open files on network shares, the exact thing this rule is there to refuse. The gap came from `fc0d5e7`, which deliberately exempted URLs naming this machine. **Fix:** after a host name, one of two leading separators is dropped before the share check, as the host does. The share check now runs whether or not a host is named. `file://localhost//server/share` and its backslash spelling still pass as local paths (`\server\share`), as before. **Tests:** - The three spellings are added to `SHARE_URLS`. `shares_are_refused_however_they_are_spelled` fails without the fix (`left: Ok("file://localhost///server/share/a.mp4")`) and passes with it. - `the_host_reads_those_spellings_as_shares` confirms Media Foundation reads each new spelling as a share. - One more local spelling is added to the cases that must still pass. **Results:** - `cargo test -p victory-hle --locked`: 155 passed, 0 failed, 2 ignored. The media tests passed 10 out of 10 runs. - `cargo clippy -p victory-hle --all-targets --locked --no-deps -- -D warnings` is clean, with and without `--all-features`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/257:upstream-pr/257'
git switch 'upstream-pr/257'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/257'
git switch 'upstream-pr/257'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/257'
git switch 'upstream-pr/257'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/257'
git switch 'main'
git merge --squash 'upstream-pr/257'
git switch 'main'
git merge --ff-only 'upstream-pr/257'
git switch 'main'
git merge 'upstream-pr/257'
git push origin 'main'
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
avatarmanz/VIctory-7900XTX!257
No description provided.