Skip to content

Commit 0674a80

Browse files
imadbzlucasfernog
andauthored
fix: assert config.bundle.identifier to be only alphanumeric, hyphens or dots. closes #4359 (#4363)
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
1 parent 8457ccc commit 0674a80

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

.changes/validate-identifier.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"cli.rs": patch
3+
"cli.js": patch
4+
---
5+
6+
Validate bundle identifier as it must only contain alphanumeric characters, hyphens and periods.

core/tauri-utils/src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ pub struct BundleConfig {
316316
/// The application identifier in reverse domain name notation (e.g. `com.tauri.example`).
317317
/// This string must be unique across applications since it is used in system configurations like
318318
/// the bundle ID and path to the webview data directory.
319+
/// This string must contain only alphanumeric characters (A–Z, a–z, and 0–9), hyphens (-),
320+
/// and periods (.).
319321
pub identifier: String,
320322
/// The app's icons
321323
#[serde(default)]

tooling/cli/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@
912912
]
913913
},
914914
"identifier": {
915-
"description": "The application identifier in reverse domain name notation (e.g. `com.tauri.example`). This string must be unique across applications since it is used in system configurations like the bundle ID and path to the webview data directory.",
915+
"description": "The application identifier in reverse domain name notation (e.g. `com.tauri.example`). This string must be unique across applications since it is used in system configurations like the bundle ID and path to the webview data directory. This string must contain only alphanumeric characters (A–Z, a–z, and 0–9), hyphens (-), and periods (.).",
916916
"type": "string"
917917
},
918918
"icon": {
@@ -2349,4 +2349,4 @@
23492349
"additionalProperties": true
23502350
}
23512351
}
2352-
}
2352+
}

tooling/cli/src/build.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ pub fn command(options: Options) -> Result<()> {
7171
std::process::exit(1);
7272
}
7373

74+
if config_
75+
.tauri
76+
.bundle
77+
.identifier
78+
.chars()
79+
.any(|ch| !(ch.is_alphanumeric() || ch == '-' || ch == '.'))
80+
{
81+
error!("You must change the bundle identifier in `tauri.conf.json > tauri > bundle > identifier`. The bundle identifier string must contain only alphanumeric characters (A–Z, a–z, and 0–9), hyphens (-), and periods (.).");
82+
std::process::exit(1);
83+
}
84+
7485
if let Some(before_build) = &config_.build.before_build_command {
7586
if !before_build.is_empty() {
7687
info!(action = "Running"; "beforeBuildCommand `{}`", before_build);

0 commit comments

Comments
 (0)