diff options
author | Tina Müller <cpan2@tinita.de> | 2018-02-02 20:59:05 +0100 |
---|---|---|
committer | Ingy döt Net <ingy@ingy.net> | 2018-06-30 15:12:39 -0700 |
commit | 20496ee288fc0cbb9416a328f39379f69a5667da (patch) | |
tree | c3e99169db3011469bdfa56c327f5819931ca19f | |
parent | 31bb2aaa34899b06f5c3666c4c9cbe44117203e5 (diff) | |
download | libyaml-git-20496ee288fc0cbb9416a328f39379f69a5667da.tar.gz |
Allow colons in plain scalars inside flow collections0.2.2-pre1
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:]`
See https://gist.github.com/perlpunk/de2c631a7b0e9002de351a680eadb573
for all the relevant cases where this change applies.
-rw-r--r-- | src/scanner.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/scanner.c b/src/scanner.c index 24e92c1..cbe5c6f 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -3430,11 +3430,22 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token) while (!IS_BLANKZ(parser->buffer)) { - /* Check for 'x:x' in the flow context. TODO: Fix the test "spec-08-13". */ + /* Check for "x:" + one of ',?[]{}' in the flow context. TODO: Fix the test "spec-08-13". + * This is not completely according to the spec + * See http://yaml.org/spec/1.1/#id907281 9.1.3. Plain + */ if (parser->flow_level && CHECK(parser->buffer, ':') - && !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) + || CHECK_AT(parser->buffer, '}', 1) + ) + ) { yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", start_mark, "found unexpected ':'"); goto error; @@ -3444,7 +3455,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, '}')))) |