From 2469f0b423518ef4bee1641f04c3283bed374567 Mon Sep 17 00:00:00 2001 From: sterni Date: Wed, 17 Feb 2021 23:48:54 +0100 Subject: fix(nix/readTree): make nixFileName only match .nix extensions Nix unfortunately has terrible escaping syntax: If something is an escape sequence it does not know, like \0, it just swallows the backslash and returns the second character (byte) as is (yes, "\0" == "0" is true). This created the following bug in nixFileName which should have resulted in at least a parse error: "(.*)\.nix" is the same as "(.*).nix" which meant that nixFileName matched anything that is at least 4 characters long and ends in "nix". This lead to readTree creating double attributes when directories are involved or attributes for non-nix files. Change-Id: Ibf3be2bd189d48881c82ee795c50151bfb365627 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2535 Reviewed-by: tazjin Tested-by: BuildkiteCI --- nix/readTree/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nix/readTree') diff --git a/nix/readTree/default.nix b/nix/readTree/default.nix index 55da146be2dc..0c323bbdc8eb 100644 --- a/nix/readTree/default.nix +++ b/nix/readTree/default.nix @@ -44,7 +44,7 @@ let else imported; nixFileName = file: - let res = match "(.*)\.nix" file; + let res = match "(.*)\\.nix" file; in if res == null then null else head res; readTree = args: initPath: parts: -- cgit 1.4.1