diff --git a/vlib/toml/checker/checker.v b/vlib/toml/checker/checker.v index 4293b62a45..b6912db8d2 100644 --- a/vlib/toml/checker/checker.v +++ b/vlib/toml/checker/checker.v @@ -437,17 +437,24 @@ fn (c Checker) check_quoted_escapes(q ast.Quoted) ? { escape := ch_byte.ascii_str() + next_ch.ascii_str() if is_basic { if q.is_multiline { - if next_ch == byte(32) { - if s.peek(1) == byte(92) { - st := s.state() - return error(@MOD + '.' + @STRUCT + '.' + @FN + - ' can not escape whitespaces before escapes in multi-line strings (`\\ \\`) at `$escape` ($st.line_nr,$st.col) in ...${c.excerpt(q.pos)}...') - } + if next_ch == ` ` { if !contains_newlines { st := s.state() return error(@MOD + '.' + @STRUCT + '.' + @FN + ' can not escape whitespaces in multi-line strings (`\\ `) at `$escape` ($st.line_nr,$st.col) in ...${c.excerpt(q.pos)}...') } + // Rest of line must only be space chars from this point on + for { + ch_ := s.next() + if ch_ == scanner.end_of_text || ch_ == `\n` { + break + } + if !(ch_ == ` ` || ch_ == `\t`) { + st := s.state() + return error(@MOD + '.' + @STRUCT + '.' + @FN + + ' invalid character `${byte(ch_).ascii_str()}` after `$escape` at ($st.line_nr,$st.col) in ...${c.excerpt(q.pos)}...') + } + } } if next_ch in [`\t`, `\n`, ` `] { s.next() diff --git a/vlib/toml/tests/alexcrichton.toml-rs-tests_test.v b/vlib/toml/tests/alexcrichton.toml-rs-tests_test.v index 46b3eac844..6199c01191 100644 --- a/vlib/toml/tests/alexcrichton.toml-rs-tests_test.v +++ b/vlib/toml/tests/alexcrichton.toml-rs-tests_test.v @@ -14,9 +14,7 @@ const ( 'valid/example-v0.4.0.toml', 'valid/datetime-truncate.toml', // Not considered valid since RFC 3339 doesn't permit > 6 ms digits ?? ] - invalid_exceptions = [ - 'invalid/string-bad-line-ending-escape.toml', - ] + invalid_exceptions = []string{} valid_value_exceptions = [ // These have correct values, and should've passed, but the format of arrays is *mixed* in the JSON ??