Skip to content

fix(cli): percent-decode request paths in the builtin dev server (fix #12763) - #16436

Merged
amrbashir merged 2 commits into
tauri-apps:devfrom
b84330808:claude/modest-gauss-jkvkge
Oct 31, 2026
Merged

amrbashir merged 2 commits into
tauri-apps:devfrom
b84330808:claude/modest-gauss-jkvkge

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

Closes #12763

The builtin dev server, which tauri dev uses when build.devUrl is not set, looked files up with the raw request path from Uri::path(), which is still percent-encoded. A stylesheet with src: url("my font.woff2") makes the webview request /my%20font.woff2. The server looked for a file literally named my%20font.woff2, did not find it and fell back to index.html. So the font, or any other file with spaces or non-ASCII characters in its name, failed to load in development. Production builds are not affected because AppManager::get_asset has percent-decoded the asset path since #1938.

This PR decodes the path the same way, with percent_decode_str(..).decode_utf8_lossy(), before the lookup. Decoding can produce .. or an absolute path (%2E%2E, %2F), but every candidate still goes through fs_read_scoped. That function canonicalizes the path and rejects anything outside of the served directory.

percent-encoding is now a direct dependency of tauri-cli. It was already in the lockfile, used by tauri and url.

Testing

  • The new dev::builtin_dev_server::tests::serves_percent_encoded_paths test calls the request handler for /my%20font.woff2 and /%E9%A1%B5%E9%9D%A2.css (页面.css) and checks that the file contents are returned. It also checks that /%2E%2E/secret.txt, /..%2Fsecret.txt and a percent-encoded absolute path don't return a file outside of the served directory. Without the fix, the first request returns index.html and the test fails.
  • cargo test -p tauri-cli, cargo clippy -p tauri-cli --all-targets -- -D warnings and cargo fmt --check pass on Linux.

I used Claude Code to write this change.

The builtin dev server, which `tauri dev` uses when `build.devUrl` is not
set, looked files up with the raw request path. A request for
`/my%20font.woff2` searched for a file literally named `my%20font.woff2`,
did not find it and fell back to `index.html`, so files with spaces or
non-ASCII characters in their names could not be loaded in development,
while they work in production builds.

Decode the path like the `tauri://` protocol does. `fs_read_scoped` still
rejects decoded paths outside of the served directory.

Fixes tauri-apps#12763

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Package Changes Through 4106246

There are 7 changes which include @tauri-apps/api with patch, tauri-bundler with patch, tauri-cli with patch, @tauri-apps/cli with patch, tauri with patch, tauri-runtime-wry with patch, tauri-utils with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
@tauri-apps/api 2.12.4 2.12.5
tauri-utils 2.10.2 2.10.3
tauri-bundler 2.10.4 2.10.5
tauri-runtime 2.12.2 2.12.3
tauri-runtime-wry 2.12.3 2.12.4
tauri-codegen 2.7.4 2.7.5
tauri-macros 2.7.4 2.7.5
tauri-plugin 2.7.2 2.7.3
tauri-build 2.7.4 2.7.5
tauri 2.12.5 2.12.6
@tauri-apps/cli 2.12.4 2.12.5
tauri-cli 2.12.4 2.12.5

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@amrbashir
amrbashir merged commit 31f29e1 into tauri-apps:dev Oct 31, 2026
27 of 29 checks passed
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.

[bug] custom font (css) in dev mode is not loading correctly when there is a space in the name, but it does in build version

2 participants