From 2eaee1d48e59e2a2c75493289e5e09aa14726f17 Mon Sep 17 00:00:00 2001 From: edef Date: Sun, 19 Nov 2023 05:55:51 +0000 Subject: fix(nix-compat/store_path): valid names ⊊ UTF-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: tazjin --- tvix/nix-compat/src/store_path/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tvix/nix-compat') 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 { -- cgit 1.4.1