Skip to content

Commit 9acd830

Browse files
authored
fix(core): percent decode asset protocol URL (#2427)
1 parent e2a0704 commit 9acd830

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Diff for: .changes/percent-decode-asset-protocol.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Use `percent_encoding::percent_decode` on the `asset` custom protocol URL before reading the file.

Diff for: core/tauri/src/manager.rs

+3
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ impl<R: Runtime> WindowManager<R> {
285285
if !webview_attributes.has_uri_scheme_protocol("asset") {
286286
webview_attributes = webview_attributes.register_uri_scheme_protocol("asset", move |url| {
287287
let path = url.replace("asset://", "");
288+
let path = percent_encoding::percent_decode(path.as_bytes())
289+
.decode_utf8_lossy()
290+
.to_string();
288291
let data = crate::async_runtime::block_on(async move { tokio::fs::read(path).await })?;
289292
Ok(data)
290293
});

0 commit comments

Comments
 (0)