nixos/dokuwiki: don’t use lib.escapeShellArg

PHP strings don't obey shell quoting rules. See #333744.
This commit is contained in:
ash 2024-09-07 14:39:07 +01:00
parent 8e971e668d
commit 345c8a7310

View File

@ -43,12 +43,12 @@ let
mkPhpValue = v: let
isHasAttr = s: isAttrs v && hasAttr s v;
in
if isString v then escapeShellArg v
if isString v then "'${escape [ "'" "\\" ] v}'"
# NOTE: If any value contains a , (comma) this will not get escaped
else if isList v && any lib.strings.isCoercibleToString v then escapeShellArg (concatMapStringsSep "," toString v)
else if isList v && any lib.strings.isCoercibleToString v then "'${escape [ "'" "\\" ] (concatMapStringsSep "," toString v)}'"
else if isInt v then toString v
else if isBool v then toString (if v then 1 else 0)
else if isHasAttr "_file" then "trim(file_get_contents(${lib.escapeShellArg v._file}))"
else if isHasAttr "_file" then "trim(file_get_contents('${escape [ "'" "\\" ] v._file}'))"
else if isHasAttr "_raw" then v._raw
else abort "The dokuwiki localConf value ${lib.generators.toPretty {} v} can not be encoded."
;
@ -59,7 +59,7 @@ let
[" = ${mkPhpValue v};"]
else
mkPhpAttrVals v;
in map (e: "[${escapeShellArg k}]${e}") (flatten values);
in map (e: "['${escape [ "'" "\\" ] k}']${e}") (flatten values);
dokuwikiLocalConfig = hostName: cfg: let
conf_gen = c: map (v: "$conf${v}") (mkPhpAttrVals c);