Skip to content
Snippets Groups Projects
Commit f4560d6bcc20 authored by Tina Müller (tinita)'s avatar Tina Müller (tinita)
Browse files

Flow indicators can not be part of local or shorthand tags (#179)

parent 6a65c52f9b06
No related branches found
No related tags found
No related merge requests found
...@@ -712,7 +712,7 @@ ...@@ -712,7 +712,7 @@
yaml_mark_t start_mark, yaml_char_t **handle); yaml_mark_t start_mark, yaml_char_t **handle);
static int static int
yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive, yaml_parser_scan_tag_uri(yaml_parser_t *parser, int uri_char, int directive,
yaml_char_t *head, yaml_mark_t start_mark, yaml_char_t **uri); yaml_char_t *head, yaml_mark_t start_mark, yaml_char_t **uri);
static int static int
...@@ -2293,7 +2293,7 @@ ...@@ -2293,7 +2293,7 @@
/* Scan a prefix. */ /* Scan a prefix. */
if (!yaml_parser_scan_tag_uri(parser, 1, NULL, start_mark, &prefix_value)) if (!yaml_parser_scan_tag_uri(parser, 1, 1, NULL, start_mark, &prefix_value))
goto error; goto error;
/* Expect a whitespace or line break. */ /* Expect a whitespace or line break. */
...@@ -2411,7 +2411,7 @@ ...@@ -2411,7 +2411,7 @@
/* Consume the tag value. */ /* Consume the tag value. */
if (!yaml_parser_scan_tag_uri(parser, 0, NULL, start_mark, &suffix)) if (!yaml_parser_scan_tag_uri(parser, 1, 0, NULL, start_mark, &suffix))
goto error; goto error;
/* Check for '>' and eat it. */ /* Check for '>' and eat it. */
...@@ -2439,10 +2439,10 @@ ...@@ -2439,10 +2439,10 @@
{ {
/* Scan the suffix now. */ /* Scan the suffix now. */
if (!yaml_parser_scan_tag_uri(parser, 0, NULL, start_mark, &suffix)) if (!yaml_parser_scan_tag_uri(parser, 0, 0, NULL, start_mark, &suffix))
goto error; goto error;
} }
else else
{ {
/* It wasn't a handle after all. Scan the rest of the tag. */ /* It wasn't a handle after all. Scan the rest of the tag. */
...@@ -2443,10 +2443,10 @@ ...@@ -2443,10 +2443,10 @@
goto error; goto error;
} }
else else
{ {
/* It wasn't a handle after all. Scan the rest of the tag. */ /* It wasn't a handle after all. Scan the rest of the tag. */
if (!yaml_parser_scan_tag_uri(parser, 0, handle, start_mark, &suffix)) if (!yaml_parser_scan_tag_uri(parser, 0, 0, handle, start_mark, &suffix))
goto error; goto error;
/* Set the handle to '!'. */ /* Set the handle to '!'. */
...@@ -2475,7 +2475,8 @@ ...@@ -2475,7 +2475,8 @@
if (!CACHE(parser, 1)) goto error; if (!CACHE(parser, 1)) goto error;
if (!IS_BLANKZ(parser->buffer)) { if (!IS_BLANKZ(parser->buffer)) {
if (!parser->flow_level || !CHECK(parser->buffer, ',') ) {
yaml_parser_set_scanner_error(parser, "while scanning a tag", yaml_parser_set_scanner_error(parser, "while scanning a tag",
start_mark, "did not find expected whitespace or line break"); start_mark, "did not find expected whitespace or line break");
goto error; goto error;
} }
...@@ -2478,7 +2479,8 @@ ...@@ -2478,7 +2479,8 @@
yaml_parser_set_scanner_error(parser, "while scanning a tag", yaml_parser_set_scanner_error(parser, "while scanning a tag",
start_mark, "did not find expected whitespace or line break"); start_mark, "did not find expected whitespace or line break");
goto error; goto error;
} }
}
end_mark = parser->mark; end_mark = parser->mark;
...@@ -2566,7 +2568,7 @@ ...@@ -2566,7 +2568,7 @@
*/ */
static int static int
yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive, yaml_parser_scan_tag_uri(yaml_parser_t *parser, int uri_char, int directive,
yaml_char_t *head, yaml_mark_t start_mark, yaml_char_t **uri) yaml_char_t *head, yaml_mark_t start_mark, yaml_char_t **uri)
{ {
size_t length = head ? strlen((char *)head) : 0; size_t length = head ? strlen((char *)head) : 0;
...@@ -2602,8 +2604,11 @@ ...@@ -2602,8 +2604,11 @@
* The set of characters that may appear in URI is as follows: * The set of characters that may appear in URI is as follows:
* *
* '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&', * '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&',
* '=', '+', '$', ',', '.', '!', '~', '*', '\'', '(', ')', '[', ']', * '=', '+', '$', '.', '!', '~', '*', '\'', '(', ')', '%'.
* '%'. *
* If we are inside a verbatim tag <...> (parameter uri_char is true)
* then also the following flow indicators are allowed:
* ',', '[', ']'
*/ */
while (IS_ALPHA(parser->buffer) || CHECK(parser->buffer, ';') while (IS_ALPHA(parser->buffer) || CHECK(parser->buffer, ';')
...@@ -2611,7 +2616,7 @@ ...@@ -2611,7 +2616,7 @@
|| CHECK(parser->buffer, ':') || CHECK(parser->buffer, '@') || CHECK(parser->buffer, ':') || CHECK(parser->buffer, '@')
|| CHECK(parser->buffer, '&') || CHECK(parser->buffer, '=') || CHECK(parser->buffer, '&') || CHECK(parser->buffer, '=')
|| CHECK(parser->buffer, '+') || CHECK(parser->buffer, '$') || CHECK(parser->buffer, '+') || CHECK(parser->buffer, '$')
|| CHECK(parser->buffer, ',') || CHECK(parser->buffer, '.') || CHECK(parser->buffer, '.') || CHECK(parser->buffer, '%')
|| CHECK(parser->buffer, '!') || CHECK(parser->buffer, '~') || CHECK(parser->buffer, '!') || CHECK(parser->buffer, '~')
|| CHECK(parser->buffer, '*') || CHECK(parser->buffer, '\'') || CHECK(parser->buffer, '*') || CHECK(parser->buffer, '\'')
|| CHECK(parser->buffer, '(') || CHECK(parser->buffer, ')') || CHECK(parser->buffer, '(') || CHECK(parser->buffer, ')')
...@@ -2615,4 +2620,6 @@ ...@@ -2615,4 +2620,6 @@
|| CHECK(parser->buffer, '!') || CHECK(parser->buffer, '~') || CHECK(parser->buffer, '!') || CHECK(parser->buffer, '~')
|| CHECK(parser->buffer, '*') || CHECK(parser->buffer, '\'') || CHECK(parser->buffer, '*') || CHECK(parser->buffer, '\'')
|| CHECK(parser->buffer, '(') || CHECK(parser->buffer, ')') || CHECK(parser->buffer, '(') || CHECK(parser->buffer, ')')
|| (uri_char && (
CHECK(parser->buffer, ',')
|| CHECK(parser->buffer, '[') || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '[') || CHECK(parser->buffer, ']')
...@@ -2618,5 +2625,6 @@ ...@@ -2618,5 +2625,6 @@
|| CHECK(parser->buffer, '[') || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '[') || CHECK(parser->buffer, ']')
|| CHECK(parser->buffer, '%')) )
))
{ {
/* Check if it is a URI-escape sequence. */ /* Check if it is a URI-escape sequence. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment