Blame SOURCES/0006-Systemd-fix-parsing-of-envvars-with-spaces-659.patch

ca4abe
From 472a143b427afc89ab2fd843cea1f1f97193ceef Mon Sep 17 00:00:00 2001
ca4abe
From: Pino Toscano <ptoscano@redhat.com>
ca4abe
Date: Tue, 4 Feb 2020 18:05:05 +0100
ca4abe
Subject: [PATCH] Systemd: fix parsing of envvars with spaces (#659)
ca4abe
ca4abe
Allow spaces inside of values quoted with single or double quotes.
ca4abe
ca4abe
This amends commit f64d8bc7a7670f3af2549fdcefb64c2b5f22cd0d that added
ca4abe
support for quoted values.
ca4abe
---
ca4abe
 lenses/systemd.aug            | 4 ++--
ca4abe
 lenses/tests/test_systemd.aug | 9 +++++++++
ca4abe
 2 files changed, 11 insertions(+), 2 deletions(-)
ca4abe
ca4abe
diff --git a/lenses/systemd.aug b/lenses/systemd.aug
ca4abe
index b868e86f..77434367 100644
ca4abe
--- a/lenses/systemd.aug
ca4abe
+++ b/lenses/systemd.aug
ca4abe
@@ -132,8 +132,8 @@ let entry_env =
ca4abe
      let envkv (env_val:lens) = key env_key . Util.del_str "=" . env_val
ca4abe
      (* bare has no spaces, and is optionally quoted *)
ca4abe
   in let bare = Quote.do_quote_opt (envkv (store /[^#'" \t\n]*[^#'" \t\n\\]/)?)
ca4abe
-  in let bare_dqval = envkv (store /"[^#" \t\n]*[^#" \t\n\\]"/)
ca4abe
-  in let bare_sqval = envkv (store /'[^#' \t\n]*[^#' \t\n\\]'/)
ca4abe
+  in let bare_dqval = envkv (store /"[^#"\t\n]*[^#"\t\n\\]"/)
ca4abe
+  in let bare_sqval = envkv (store /'[^#'\t\n]*[^#'\t\n\\]'/)
ca4abe
      (* quoted has at least one space, and must be quoted *)
ca4abe
   in let quoted = Quote.do_quote (envkv (store /[^#"'\n]*[ \t]+[^#"'\n]*/))
ca4abe
   in let envkv_quoted = [ bare ] | [ bare_dqval ] | [ bare_sqval ] | [ quoted ]
ca4abe
diff --git a/lenses/tests/test_systemd.aug b/lenses/tests/test_systemd.aug
ca4abe
index 3397456e..19c57075 100644
ca4abe
--- a/lenses/tests/test_systemd.aug
ca4abe
+++ b/lenses/tests/test_systemd.aug
ca4abe
@@ -206,6 +206,8 @@ FOO=BAR
ca4abe
 Environment=\"LANG=foo bar\" FOO=BAR
ca4abe
 Environment=OPTIONS=\"-LS0-6d\"
ca4abe
 Environment=OPTIONS='-LS0-6d'
ca4abe
+Environment=VAR=\"with some spaces\" VAR2='more spaces'
ca4abe
+Environment=VAR='with some spaces'
ca4abe
 "
ca4abe
 (* Test: Systemd.lns *)
ca4abe
 test Systemd.lns get env =
ca4abe
@@ -247,6 +249,13 @@ test Systemd.lns get env =
ca4abe
     { "Environment"
ca4abe
       { "OPTIONS" = "'-LS0-6d'" }
ca4abe
     }
ca4abe
+    { "Environment"
ca4abe
+      { "VAR" = "\"with some spaces\"" }
ca4abe
+      { "VAR2" = "'more spaces'" }
ca4abe
+    }
ca4abe
+    { "Environment"
ca4abe
+      { "VAR" = "'with some spaces'" }
ca4abe
+    }
ca4abe
   }
ca4abe
 
ca4abe
 (* Variable: unit *)
ca4abe
-- 
2ac116
2.29.2
ca4abe