ソースを参照

fix: assert config.bundle.identifier to be only alphanumeric, hyphens or dots. closes #4359 (#4363)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Imad Bouziani 3 年 前
コミット
0674a80129

+ 6 - 0
.changes/validate-identifier.md

@@ -0,0 +1,6 @@
+---
+"cli.rs": patch
+"cli.js": patch
+---
+
+Validate bundle identifier as it must only contain alphanumeric characters, hyphens and periods.

+ 2 - 0
core/tauri-utils/src/config.rs

@@ -316,6 +316,8 @@ pub struct BundleConfig {
   /// 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 (.).
   pub identifier: String,
   /// The app's icons
   #[serde(default)]

+ 2 - 2
tooling/cli/schema.json

@@ -912,7 +912,7 @@
           ]
         },
         "identifier": {
-          "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.",
+          "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 (.).",
           "type": "string"
         },
         "icon": {
@@ -2349,4 +2349,4 @@
       "additionalProperties": true
     }
   }
-}
+}

+ 11 - 0
tooling/cli/src/build.rs

@@ -71,6 +71,17 @@ pub fn command(options: Options) -> Result<()> {
     std::process::exit(1);
   }
 
+  if config_
+    .tauri
+    .bundle
+    .identifier
+    .chars()
+    .any(|ch| !(ch.is_alphanumeric() || ch == '-' || ch == '.'))
+  {
+    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 (.).");
+    std::process::exit(1);
+  }
+
   if let Some(before_build) = &config_.build.before_build_command {
     if !before_build.is_empty() {
       info!(action = "Running"; "beforeBuildCommand `{}`", before_build);