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

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