fix(tvix/nix-compat): reject dotfiles
Nix has historically rejected these. The current behaviour was accidentally introduced in Nix 2.4, and is considered a bug. Link: https://github.com/NixOS/nix/pull/9095 Change-Id: I38ffa911f0a413086479bd972de09671dbe85121 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9507 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Autosubmit: edef <edef@edef.eu>
This commit is contained in:
parent
9a7c078a69
commit
155f53b264
1 changed files with 7 additions and 5 deletions
|
@ -163,9 +163,9 @@ pub(crate) fn validate_name(s: &[u8]) -> Result<String, Error> {
|
|||
|
||||
for (i, c) in s.iter().enumerate() {
|
||||
if c.is_ascii_alphanumeric()
|
||||
|| (*c == b'.' && i != 0) // can't start with a dot
|
||||
|| *c == b'-'
|
||||
|| *c == b'_'
|
||||
|| *c == b'.'
|
||||
|| *c == b'+'
|
||||
|| *c == b'?'
|
||||
|| *c == b'='
|
||||
|
@ -221,13 +221,15 @@ mod tests {
|
|||
assert_eq!(example_nix_path_str, nixpath.to_string())
|
||||
}
|
||||
|
||||
/// This is the store path produced after `nix-store --add`'ing an
|
||||
/// This is the store path rejected 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.
|
||||
#[test]
|
||||
fn starts_with_dot() {
|
||||
let nix_path_str = "fli4bwscgna7lpm7v5xgnjxrxh0yc7ra-.gitignore";
|
||||
let nixpath = StorePath::from_bytes(nix_path_str.as_bytes()).expect("must succeed");
|
||||
assert_eq!(".gitignore", nixpath.name);
|
||||
StorePath::from_bytes(b"fli4bwscgna7lpm7v5xgnjxrxh0yc7ra-.gitignore")
|
||||
.expect_err("must fail");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue