From 5c77fd4e5a120c4b44815610e8e764acdf0f19c6 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Mon, 23 Sep 2024 16:42:54 -0300 Subject: [PATCH] fix: percent decode command name fixes plugin invocations closes https://github.com/tauri-apps/tauri/issues/11072 --- .changes/fix-parse-command-name.md | 5 +++++ Cargo.lock | 1 + Cargo.toml | 1 + src/lib.rs | 3 ++- 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changes/fix-parse-command-name.md diff --git a/.changes/fix-parse-command-name.md b/.changes/fix-parse-command-name.md new file mode 100644 index 0000000..8819b67 --- /dev/null +++ b/.changes/fix-parse-command-name.md @@ -0,0 +1,5 @@ +--- +"tauri-invoke-http": patch +--- + +Properly parse window label and command name on Android (percent encoding). diff --git a/Cargo.lock b/Cargo.lock index 1b5511b..985a9e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3127,6 +3127,7 @@ dependencies = [ "http-body-util", "hyper", "log", + "percent-encoding", "pin-project-lite", "portpicker", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index eafdd1c..a899b17 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,3 +26,4 @@ portpicker = "0.1" serde_json = "1.0" tokio = { version = "1", features = ["net"] } log = "0.4" +percent-encoding = "2.3" diff --git a/src/lib.rs b/src/lib.rs index 9b13df1..4886855 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,6 +16,7 @@ use hyper::{ service::service_fn, HeaderMap, Method, Request, Response, StatusCode, }; +use percent_encoding::percent_decode_str; use tauri::{ http::HeaderName, ipc::{CallbackFn, InvokeBody, InvokeResponse}, @@ -166,7 +167,7 @@ async fn handle_request( let url = request.uri().to_string(); let pieces = url.split('/').collect::>(); let window_label = pieces[1]; - let cmd = pieces[2]; + let cmd = percent_decode_str(pieces[2]).decode_utf8()?; if let Some(window) = app.get_webview_window(window_label) { let content_type = request