Skip to content

Commit 4a3aece

Browse files
committed
fix: only allow ascii characters for name fields
watusi for example has a weird ascii character in its name, so we need to strip this out
1 parent cb869af commit 4a3aece

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

crates/core/src/utils/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ pub use certificate::CertificateIdentity;
99
pub fn strip_invalid_name_chars(name: &str) -> String {
1010
let invalid_chars = ['\\', '/', ':', '*', '?', '"', '<', '>', '|', '.'];
1111
name.chars()
12-
.filter(|c| !invalid_chars.contains(c))
12+
.filter(|c| !invalid_chars.contains(c) && !c.is_control() && c.is_ascii())
1313
.collect()
1414
}

crates/utils/src/device.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ impl Device {
140140
fs::symlink(PathBuf::from("Wrapper").join(app_name), &wrapped_bundle_path).await?;
141141

142142
let applications_dir = PathBuf::from("/Applications").join(app_name);
143-
fs::rename(&outer_app_dir, &applications_dir).await?;
143+
fs::rename(&outer_app_dir, &applications_dir).await
144+
.map_err(|_| Error::BundleFailedToCopy(applications_dir.to_string_lossy().into_owned()))?;
144145

145146
Ok(())
146147
}

crates/utils/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ use thiserror::Error as ThisError;
2121
pub enum Error {
2222
#[error("Info.plist not found")]
2323
BundleInfoPlistMissing,
24+
25+
// MARK: - Device errors
26+
#[error("Bundle failed to rename, make sure its available: {0}")]
27+
BundleFailedToCopy(String),
28+
2429
#[error("Zip error: {0}")]
2530
Zip(#[from] zip::result::ZipError),
2631
#[error("Info.plist not found")]

0 commit comments

Comments
 (0)