fix(nix-compat/store_path): permit store paths with dots again
Nix 2.4 accidentally permitted this behaviour, but the revert came too late to beat Hyrum's law. It is now considered permissible. Link: https://github.com/NixOS/nix/pull/9867 Change-Id: Ie97777af6765fe1c12c8aa593afe1c9b69125775 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11553 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
parent
c5b3187002
commit
d84fd49169
1 changed files with 8 additions and 10 deletions
|
@ -303,8 +303,7 @@ impl Serialize for StorePathRef<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
/// NAME_CHARS contains `true` for bytes that are valid in store path names,
|
||||
/// not accounting for '.' being permitted only past the first character.
|
||||
/// NAME_CHARS contains `true` for bytes that are valid in store path names.
|
||||
static NAME_CHARS: [bool; 256] = {
|
||||
let mut tbl = [false; 256];
|
||||
let mut c = 0;
|
||||
|
@ -332,10 +331,6 @@ pub(crate) fn validate_name(s: &(impl AsRef<[u8]> + ?Sized)) -> Result<&str, Err
|
|||
return Err(Error::InvalidLength);
|
||||
}
|
||||
|
||||
if s[0] == b'.' {
|
||||
return Err(Error::InvalidName(s.to_vec(), 0));
|
||||
}
|
||||
|
||||
let mut valid = true;
|
||||
for &c in s {
|
||||
valid = valid && NAME_CHARS[c as usize];
|
||||
|
@ -446,15 +441,18 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
/// This is the store path rejected when `nix-store --add`'ing an
|
||||
/// This is the store path *accepted* when `nix-store --add`'ing an
|
||||
/// empty `.gitignore` file.
|
||||
///
|
||||
/// Nix 2.4 accidentally dropped this behaviour, but this is considered a bug.
|
||||
/// See https://github.com/NixOS/nix/pull/9095.
|
||||
/// Nix 2.4 accidentally permitted this behaviour, but the revert came
|
||||
/// too late to beat Hyrum's law. It is now considered permissible.
|
||||
///
|
||||
/// https://github.com/NixOS/nix/pull/9095 (revert)
|
||||
/// https://github.com/NixOS/nix/pull/9867 (revert-of-revert)
|
||||
#[test]
|
||||
fn starts_with_dot() {
|
||||
StorePath::from_bytes(b"fli4bwscgna7lpm7v5xgnjxrxh0yc7ra-.gitignore")
|
||||
.expect_err("must fail");
|
||||
.expect("must succeed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue