From 9ef1be46e89794334313359879868c98f47167c0 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Fri, 20 Sep 2024 13:57:47 +0300 Subject: [PATCH] fix(updater): encode version when making requests (#11070) * fix(updater): encode version when making requests closes #10908 * encode `+` only * use normal const --- .changes/updater-endpoint-version-encoded.md | 5 +++++ core/tauri/src/updater/core.rs | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changes/updater-endpoint-version-encoded.md diff --git a/.changes/updater-endpoint-version-encoded.md b/.changes/updater-endpoint-version-encoded.md new file mode 100644 index 000000000000..e248a0026a21 --- /dev/null +++ b/.changes/updater-endpoint-version-encoded.md @@ -0,0 +1,5 @@ +--- +'tauri': 'patch:bug' +--- + +Encode `+` when making updater requests which can be cause incorrectly interpolating the endpoint when using `{{current_version}}` in the endpoint where the current version contains a build number, for example `1.8.0+1`. diff --git a/core/tauri/src/updater/core.rs b/core/tauri/src/updater/core.rs index 13a40936f983..ae931b392993 100644 --- a/core/tauri/src/updater/core.rs +++ b/core/tauri/src/updater/core.rs @@ -15,6 +15,7 @@ use http::{ HeaderMap, StatusCode, }; use minisign_verify::{PublicKey, Signature}; +use percent_encoding::{AsciiSet, CONTROLS}; use semver::Version; use serde::{de::Error as DeError, Deserialize, Deserializer, Serialize}; use tauri_utils::{platform::current_exe, Env}; @@ -374,8 +375,12 @@ impl UpdateBuilder { // https://releases.myapp.com/update/darwin/aarch64/1.0.0 // The main objective is if the update URL is defined via the Cargo.toml // the URL will be generated dynamically + let version = self.current_version.to_string(); + const CONTROLS_ADD: &AsciiSet = &CONTROLS.add(b'+'); + let encoded_version = percent_encoding::percent_encode(version.as_bytes(), CONTROLS_ADD); + let fixed_link = url - .replace("{{current_version}}", &self.current_version.to_string()) + .replace("{{current_version}}", &encoded_version.to_string()) .replace("{{target}}", &target) .replace("{{arch}}", arch);