Skip to content

Commit f41d360

Browse files
committed
1 parent cf53b3b commit f41d360

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/scanner.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ yaml_parser_scan_tag_handle(yaml_parser_t *parser, int directive,
712712
yaml_mark_t start_mark, yaml_char_t **handle);
713713

714714
static int
715-
yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive,
715+
yaml_parser_scan_tag_uri(yaml_parser_t *parser, int uri_char, int directive,
716716
yaml_char_t *head, yaml_mark_t start_mark, yaml_char_t **uri);
717717

718718
static int
@@ -2293,7 +2293,7 @@ yaml_parser_scan_tag_directive_value(yaml_parser_t *parser,
22932293

22942294
/* Scan a prefix. */
22952295

2296-
if (!yaml_parser_scan_tag_uri(parser, 1, NULL, start_mark, &prefix_value))
2296+
if (!yaml_parser_scan_tag_uri(parser, 1, 1, NULL, start_mark, &prefix_value))
22972297
goto error;
22982298

22992299
/* Expect a whitespace or line break. */
@@ -2411,7 +2411,7 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
24112411

24122412
/* Consume the tag value. */
24132413

2414-
if (!yaml_parser_scan_tag_uri(parser, 0, NULL, start_mark, &suffix))
2414+
if (!yaml_parser_scan_tag_uri(parser, 1, 0, NULL, start_mark, &suffix))
24152415
goto error;
24162416

24172417
/* Check for '>' and eat it. */
@@ -2439,14 +2439,14 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
24392439
{
24402440
/* Scan the suffix now. */
24412441

2442-
if (!yaml_parser_scan_tag_uri(parser, 0, NULL, start_mark, &suffix))
2442+
if (!yaml_parser_scan_tag_uri(parser, 0, 0, NULL, start_mark, &suffix))
24432443
goto error;
24442444
}
24452445
else
24462446
{
24472447
/* It wasn't a handle after all. Scan the rest of the tag. */
24482448

2449-
if (!yaml_parser_scan_tag_uri(parser, 0, handle, start_mark, &suffix))
2449+
if (!yaml_parser_scan_tag_uri(parser, 0, 0, handle, start_mark, &suffix))
24502450
goto error;
24512451

24522452
/* Set the handle to '!'. */
@@ -2475,9 +2475,11 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
24752475
if (!CACHE(parser, 1)) goto error;
24762476

24772477
if (!IS_BLANKZ(parser->buffer)) {
2478-
yaml_parser_set_scanner_error(parser, "while scanning a tag",
2479-
start_mark, "did not find expected whitespace or line break");
2480-
goto error;
2478+
if (!parser->flow_level || !CHECK(parser->buffer, ',') ) {
2479+
yaml_parser_set_scanner_error(parser, "while scanning a tag",
2480+
start_mark, "did not find expected whitespace or line break");
2481+
goto error;
2482+
}
24812483
}
24822484

24832485
end_mark = parser->mark;
@@ -2566,7 +2568,7 @@ yaml_parser_scan_tag_handle(yaml_parser_t *parser, int directive,
25662568
*/
25672569

25682570
static int
2569-
yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive,
2571+
yaml_parser_scan_tag_uri(yaml_parser_t *parser, int uri_char, int directive,
25702572
yaml_char_t *head, yaml_mark_t start_mark, yaml_char_t **uri)
25712573
{
25722574
size_t length = head ? strlen((char *)head) : 0;
@@ -2602,21 +2604,27 @@ yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive,
26022604
* The set of characters that may appear in URI is as follows:
26032605
*
26042606
* '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&',
2605-
* '=', '+', '$', ',', '.', '!', '~', '*', '\'', '(', ')', '[', ']',
2606-
* '%'.
2607+
* '=', '+', '$', '.', '!', '~', '*', '\'', '(', ')', '%'.
2608+
*
2609+
* If we are inside a verbatim tag <...> (parameter uri_char is true)
2610+
* then also the following flow indicators are allowed:
2611+
* ',', '[', ']'
26072612
*/
26082613

26092614
while (IS_ALPHA(parser->buffer) || CHECK(parser->buffer, ';')
26102615
|| CHECK(parser->buffer, '/') || CHECK(parser->buffer, '?')
26112616
|| CHECK(parser->buffer, ':') || CHECK(parser->buffer, '@')
26122617
|| CHECK(parser->buffer, '&') || CHECK(parser->buffer, '=')
26132618
|| CHECK(parser->buffer, '+') || CHECK(parser->buffer, '$')
2614-
|| CHECK(parser->buffer, ',') || CHECK(parser->buffer, '.')
2619+
|| CHECK(parser->buffer, '.') || CHECK(parser->buffer, '%')
26152620
|| CHECK(parser->buffer, '!') || CHECK(parser->buffer, '~')
26162621
|| CHECK(parser->buffer, '*') || CHECK(parser->buffer, '\'')
26172622
|| CHECK(parser->buffer, '(') || CHECK(parser->buffer, ')')
2618-
|| CHECK(parser->buffer, '[') || CHECK(parser->buffer, ']')
2619-
|| CHECK(parser->buffer, '%'))
2623+
|| (uri_char && (
2624+
CHECK(parser->buffer, ',')
2625+
|| CHECK(parser->buffer, '[') || CHECK(parser->buffer, ']')
2626+
)
2627+
))
26202628
{
26212629
/* Check if it is a URI-escape sequence. */
26222630

0 commit comments

Comments
 (0)