Skip to content

Commit

Permalink
fix(core): percent decode asset protocol URL (#2427)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Aug 14, 2021
1 parent e2a0704 commit 9acd830
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/percent-decode-asset-protocol.md
@@ -0,0 +1,5 @@
---
"tauri": patch
---

Use `percent_encoding::percent_decode` on the `asset` custom protocol URL before reading the file.
3 changes: 3 additions & 0 deletions core/tauri/src/manager.rs
Expand Up @@ -285,6 +285,9 @@ impl<R: Runtime> WindowManager<R> {
if !webview_attributes.has_uri_scheme_protocol("asset") {
webview_attributes = webview_attributes.register_uri_scheme_protocol("asset", move |url| {
let path = url.replace("asset://", "");
let path = percent_encoding::percent_decode(path.as_bytes())
.decode_utf8_lossy()
.to_string();
let data = crate::async_runtime::block_on(async move { tokio::fs::read(path).await })?;
Ok(data)
});
Expand Down

0 comments on commit 9acd830

Please sign in to comment.