about summary refs log tree commit diff
path: root/tvix/nix-compat/src/store_path/mod.rs
diff options
context:
space:
mode:
authoredef <edef@edef.eu>2023-11-19T05·55+0000
committeredef <edef@edef.eu>2023-11-19T09·53+0000
commit2eaee1d48e59e2a2c75493289e5e09aa14726f17 (patch)
tree4919392dc66b0cb847ee400e66236f120ae053c7 /tvix/nix-compat/src/store_path/mod.rs
parent9ad7cc629e20e4cdb5420e20addae8909e83d610 (diff)
fix(nix-compat/store_path): valid names ⊊ UTF-8 r/7033
We don't need to validate UTF-8 separately, since valid names are
a strict subset of ASCII, and therefore a strict subset of UTF-8.

Change-Id: I3261bf0efe3480b5b315074efafcf5e47a6c5a65
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10087
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/nix-compat/src/store_path/mod.rs')
-rw-r--r--tvix/nix-compat/src/store_path/mod.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/tvix/nix-compat/src/store_path/mod.rs b/tvix/nix-compat/src/store_path/mod.rs
index c54ed3710123..93a1f0e88924 100644
--- a/tvix/nix-compat/src/store_path/mod.rs
+++ b/tvix/nix-compat/src/store_path/mod.rs
@@ -261,7 +261,8 @@ pub(crate) fn validate_name(s: &(impl AsRef<[u8]> + ?Sized)) -> Result<&str, Err
         unreachable!();
     }
 
-    Ok(str::from_utf8(s).unwrap())
+    // SAFETY: We permit a subset of ASCII, which guarantees valid UTF-8.
+    Ok(unsafe { str::from_utf8_unchecked(s) })
 }
 
 impl fmt::Display for StorePath {