about summary refs log tree commit diff
path: root/shared/systemd/src/basic/env-file.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2020-10-05 22:28:16 +0200
committerMichael Biebl <biebl@debian.org>2020-10-05 22:28:16 +0200
commit47a2114d6f697a31d84c8874c49e94dd04119d75 (patch)
treee3022686ff1956d7f17f1f7cdf7022ce980b7a5c /shared/systemd/src/basic/env-file.c
parent9d722f3d3492e31c0b3e4bcba603ffd65309c621 (diff)
parentaafc1dbe4712c86189bbc1d4d54ad8cb4c69be7e (diff)
Update upstream source from tag 'upstream/1.27.90'
Update to upstream version '1.27.90'
with Debian dir 72a0791efa5966be1724a82dfcac90f6cd22bd1b
Diffstat (limited to 'shared/systemd/src/basic/env-file.c')
-rw-r--r--shared/systemd/src/basic/env-file.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/shared/systemd/src/basic/env-file.c b/shared/systemd/src/basic/env-file.c
index 30ee135a..1e93f18e 100644
--- a/shared/systemd/src/basic/env-file.c
+++ b/shared/systemd/src/basic/env-file.c
@@ -211,17 +211,21 @@ static int parse_env_file_internal(
                 case DOUBLE_QUOTE_VALUE_ESCAPE:
                         state = DOUBLE_QUOTE_VALUE;
 
-                        if (c == '"') {
+                        if (strchr(SHELL_NEED_ESCAPE, c)) {
+                                /* If this is a char that needs escaping, just unescape it. */
                                 if (!GREEDY_REALLOC(value, value_alloc, n_value+2))
                                         return -ENOMEM;
-                                value[n_value++] = '"';
-                        } else if (!strchr(NEWLINE, c)) {
+                                value[n_value++] = c;
+                        } else if (c != '\n') {
+                                /* If other char than what needs escaping, keep the "\" in place, like the
+                                 * real shell does. */
                                 if (!GREEDY_REALLOC(value, value_alloc, n_value+3))
                                         return -ENOMEM;
                                 value[n_value++] = '\\';
                                 value[n_value++] = c;
                         }
 
+                        /* Escaped newlines (aka "continuation lines") are eaten up entirely */
                         break;
 
                 case COMMENT: