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