mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
toml: support checking and decoding quoted keys (#12552)
This commit is contained in:
@ -1061,16 +1061,25 @@ pub fn (mut p Parser) key() ?ast.Key {
|
||||
' key expected .bare, .underscore, .number, .quoted or .boolean but got "$p.tok.kind"')
|
||||
}
|
||||
|
||||
// A small exception that can't easily be done via `checker`
|
||||
// since the `is_multiline` information is lost when using the key.text as a
|
||||
// A few small exceptions that can't easily be done via `checker` or `decoder` *after* the
|
||||
// main table has been build since information like `is_multiline` is lost when using the key.text as a
|
||||
// V `map` key directly.
|
||||
if p.config.run_checks {
|
||||
if key is ast.Quoted {
|
||||
if key is ast.Quoted {
|
||||
if p.config.run_checks {
|
||||
quoted := key as ast.Quoted
|
||||
if quoted.is_multiline {
|
||||
return error(@MOD + '.' + @STRUCT + '.' + @FN +
|
||||
' multiline string as key is not allowed. (excerpt): "...${p.excerpt()}..."')
|
||||
}
|
||||
chckr := checker.Checker{
|
||||
scanner: p.scanner
|
||||
}
|
||||
chckr.check_quoted(quoted) ?
|
||||
}
|
||||
if p.config.decode_values {
|
||||
mut quoted := key as ast.Quoted
|
||||
decoder.decode_quoted_escapes(mut quoted) ?
|
||||
key = ast.Key(quoted)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user