Skip to content

Commit 88d2308

Browse files
committed
Warn on an escaped CR in wsl.conf instead of dropping it silently
`case '\r': break;` made a backslash before a CR the only unrecognised escape the parser accepts without a diagnostic. In a CRLF file that left the value truncated at the backslash and the remainder parsed as its own line, with nothing reported. Letting it fall into the default case gives the same MessageConfigInvalidEscape warning as any other bad escape. As with those, the line is then discarded rather than kept truncated.
1 parent eaa69e7 commit 88d2308

2 files changed

Lines changed: 1 addition & 3 deletions

File tree

‎src/shared/configfile/configfile.cpp‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,9 +709,6 @@ int ParseConfigFile(std::vector<ConfigKey>& keys, FILE* file, int flags, const w
709709
value += '\t';
710710
break;
711711

712-
case '\r':
713-
break;
714-
715712
case '\n':
716713
// Line continuation. Skip both characters.
717714
line++;

‎test/windows/UnitTests.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,6 +2181,7 @@ Arguments for managing distributions in Windows Subsystem for Linux:
21812181

21822182
validateWarnings(L"[foo]\na=b", L"wsl: Unknown key 'foo.a' in /etc/wsl.conf:2\r\n");
21832183
validateWarnings(L"a=a\\m", L"wsl: Invalid escaped character: 'm' in /etc/wsl.conf:1\r\n");
2184+
validateWarnings(L"a=a\\\r\n", L"wsl: Invalid escaped character: '\r' in /etc/wsl.conf:1\r\n");
21842185
validateWarnings(L"[=b", L"wsl: Invalid section name in /etc/wsl.conf:1\r\n");
21852186
validateWarnings(L"\r\n\r\n[foo]\r\na=b", L"wsl: Unknown key 'foo.a' in /etc/wsl.conf:5\r\n");
21862187

0 commit comments

Comments
 (0)