From e1fbb74b41e773bf81f8095710980bb99518e841 Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Sat, 8 Aug 2020 12:00:00 +0000 Subject: [PATCH] lib.gvariant: escape backslashes in strings PR #1433 --- modules/lib/gvariant.nix | 2 +- tests/lib/types/gvariant-merge.nix | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/lib/gvariant.nix b/modules/lib/gvariant.nix index 3bfa18cb4..92aa7d983 100644 --- a/modules/lib/gvariant.nix +++ b/modules/lib/gvariant.nix @@ -123,7 +123,7 @@ in rec { mkString = v: mkPrimitive type.string v // { - __toString = self: "'${escape [ "'" ] self.value}'"; + __toString = self: "'${escape [ "'" "\\" ] self.value}'"; }; mkObjectpath = v: diff --git a/tests/lib/types/gvariant-merge.nix b/tests/lib/types/gvariant-merge.nix index fce50e0da..867534c1f 100644 --- a/tests/lib/types/gvariant-merge.nix +++ b/tests/lib/types/gvariant-merge.nix @@ -26,6 +26,7 @@ in { { string = "foo"; } { string = "foo"; } + { escapedString = "' \\"; } { tuple = mkTuple [ 1 [ "foo" ] ]; } @@ -46,6 +47,7 @@ in { bool = true emptyArray1 = @as [] emptyArray2 = @as [] + escapedString = '\' \\' float = 3.140000 int = 42 list = @as ['one','two']