Skip to content

Commit

Permalink
fix(updater): encode version when making requests (#11070)
Browse files Browse the repository at this point in the history
* fix(updater): encode version when making requests

closes #10908

* encode `+` only

* use normal const
  • Loading branch information
amrbashir committed Sep 20, 2024
1 parent bd3c153 commit 9ef1be4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/updater-endpoint-version-encoded.md
Original file line number Diff line number Diff line change
@@ -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`.
7 changes: 6 additions & 1 deletion core/tauri/src/updater/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -374,8 +375,12 @@ impl<R: Runtime> UpdateBuilder<R> {
// 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);

Expand Down

0 comments on commit 9ef1be4

Please sign in to comment.