◐ Shell
clean mode source ↗

src: fix env-file flag to ignore spaces before quotes · nodejs/node@aff9a53

Commit aff9a53

MOHIT51196marco-ippolito

authored and

committed

src: fix env-file flag to ignore spaces before quotes

Fix to ignore spaces between '=' and quoted string in env file Fixes: #53461 Signed-off-by: Mohit Malhotra <dev.mohitmalhotra@gmail.com> PR-URL: #53786 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>

3 files changed

Lines changed: 4 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions

Original file line numberDiff line numberDiff line change

@@ -129,6 +129,7 @@ void Dotenv::ParseContent(const std::string_view input) {

129129

key = content.substr(0, equal);

130130

content.remove_prefix(equal + 1);

131131

key = trim_spaces(key);

132+

content = trim_spaces(content);

132133
133134

if (key.empty()) {

134135

break;

Lines changed: 1 addition & 0 deletions

Original file line numberDiff line numberDiff line change

@@ -38,6 +38,7 @@ RETAIN_INNER_QUOTES={"foo": "bar"}

3838

RETAIN_INNER_QUOTES_AS_STRING='{"foo": "bar"}'

3939

RETAIN_INNER_QUOTES_AS_BACKTICKS=`{"foo": "bar's"}`

4040

TRIM_SPACE_FROM_UNQUOTED= some spaced out string

41+

SPACE_BEFORE_DOUBLE_QUOTES= "space before double quotes"

4142

EMAIL=therealnerdybeast@example.tld

4243

SPACED_KEY = parsed

4344

EDGE_CASE_INLINE_COMMENTS="VALUE1" # or "VALUE2" or "VALUE3"

Lines changed: 2 additions & 0 deletions

Original file line numberDiff line numberDiff line change

@@ -80,3 +80,5 @@ assert.strictEqual(process.env.DONT_EXPAND_UNQUOTED, 'dontexpand\\nnewlines');

8080

assert.strictEqual(process.env.DONT_EXPAND_SQUOTED, 'dontexpand\\nnewlines');

8181

// Ignore export before key

8282

assert.strictEqual(process.env.EXPORT_EXAMPLE, 'ignore export');

83+

// Ignore spaces before double quotes to avoid quoted strings as value

84+

assert.strictEqual(process.env.SPACE_BEFORE_DOUBLE_QUOTES, 'space before double quotes');

0 commit comments