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 <mail@tazj.in>
Tested-by: BuildkiteCI
This commit is contained in:
sterni 2021-02-17 23:48:54 +01:00
parent fa99c128f8
commit 2469f0b423

View file

@ -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: