From baeec9e348bd130befbbfcad0e9c2342caada7c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tina=20M=C3=BCller?= Date: Fri, 2 Feb 2018 20:59:05 +0100 Subject: [PATCH] Allow colons in plain scalars inside flow collections This is a followup to #28 See http://yaml.org/spec/1.1/#nb-plain-char(c) and the following productions. This commit will allow `[http://example]`, but still fail for: - `[:foo]` - `[foo:]` --- src/scanner.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/scanner.c b/src/scanner.c index b6f5185f..0ba9eccd 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -3434,7 +3434,17 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token) if (parser->flow_level && CHECK(parser->buffer, ':') - && !IS_BLANKZ_AT(parser->buffer, 1)) { + && ( + !IS_BLANKZ_AT(parser->buffer, 1) + && ( + CHECK_AT(parser->buffer, ',', 1) + || CHECK_AT(parser->buffer, '[', 1) + || CHECK_AT(parser->buffer, ']', 1) + || CHECK_AT(parser->buffer, '{', 1) + || CHECK_AT(parser->buffer, '}', 1) + ) + ) + ) { yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", start_mark, "found unexpected ':'"); goto error; @@ -3444,7 +3454,7 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token) if ((CHECK(parser->buffer, ':') && IS_BLANKZ_AT(parser->buffer, 1)) || (parser->flow_level && - (CHECK(parser->buffer, ',') || CHECK(parser->buffer, ':') + (CHECK(parser->buffer, ',') || CHECK(parser->buffer, '?') || CHECK(parser->buffer, '[') || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '{') || CHECK(parser->buffer, '}'))))