Skip to content

Commit d582ac0

Browse files
committed
nixos/wordpress: fix tests
1 parent d0cbaf4 commit d582ac0

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

nixos/modules/services/web-apps/wordpress.nix

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,16 @@ let
7575

7676
mkPhpValue = v: let
7777
isHasAttr = s: isAttrs v && hasAttr s v;
78+
# "you're escaped" -> "'you\'re escaped'"
79+
# https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single
80+
toPhpString = s: "'${escape [ "'" "\\" ] s}'";
7881
in
79-
if isString v then escapeShellArg v
82+
if isString v then toPhpString v
8083
# NOTE: If any value contains a , (comma) this will not get escaped
81-
else if isList v && any lib.strings.isCoercibleToString v then escapeShellArg (concatMapStringsSep "," toString v)
84+
else if isList v && any lib.strings.isCoercibleToString v then toPhpString (concatMapStringsSep "," toString v)
8285
else if isInt v then toString v
8386
else if isBool v then boolToString v
84-
else if isHasAttr "_file" then "trim(file_get_contents(${lib.escapeShellArg v._file}))"
87+
else if isHasAttr "_file" then "trim(file_get_contents(${toPhpString v._file}))"
8588
else if isHasAttr "_raw" then v._raw
8689
else abort "The Wordpress config value ${lib.generators.toPretty {} v} can not be encoded."
8790
;

nixos/tests/wordpress.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ rec {
1111
};
1212

1313
nodes = lib.foldl (a: version: let
14-
package = pkgs."wordpress${version}";
14+
package = pkgs."wordpress_${version}";
1515
in a // {
1616
"wp${version}_httpd" = _: {
1717
services.httpd.adminAddr = "[email protected]";
@@ -67,7 +67,7 @@ rec {
6767
networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
6868
};
6969
}) {} [
70-
"6_3" "6_4"
70+
"6_5" "6_6"
7171
];
7272

7373
testScript = ''

0 commit comments

Comments
 (0)