@@ -1944,7 +1944,7 @@ func yaml_parser_scan_tag_handle(parser *yaml_parser_t, directive bool, start_ma
19441944 } else {
19451945 // It's either the '!' tag or not really a tag handle. If it's a %TAG
19461946 // directive, it's an error. If it's a tag token, it must be a part of URI.
1947- if directive && ! ( s [ 0 ] == '!' && s [ 1 ] == 0 ) {
1947+ if directive && string ( s ) != "!" {
19481948 yaml_parser_set_scanner_tag_error (parser , directive ,
19491949 start_mark , "did not find expected '!'" )
19501950 return false
@@ -1959,12 +1959,12 @@ func yaml_parser_scan_tag_handle(parser *yaml_parser_t, directive bool, start_ma
19591959func yaml_parser_scan_tag_uri (parser * yaml_parser_t , directive bool , head []byte , start_mark yaml_mark_t , uri * []byte ) bool {
19601960 //size_t length = head ? strlen((char *)head) : 0
19611961 var s []byte
1962- length := len (head )
1962+ hasTag := len (head ) > 0
19631963
19641964 // Copy the head if needed.
19651965 //
19661966 // Note that we don't copy the leading '!' character.
1967- if length > 0 {
1967+ if len ( head ) > 1 {
19681968 s = append (s , head [1 :]... )
19691969 }
19701970
@@ -1997,15 +1997,14 @@ func yaml_parser_scan_tag_uri(parser *yaml_parser_t, directive bool, head []byte
19971997 }
19981998 } else {
19991999 s = read (parser , s )
2000- length ++
20012000 }
20022001 if parser .unread < 1 && ! yaml_parser_update_buffer (parser , 1 ) {
20032002 return false
20042003 }
2004+ hasTag = true
20052005 }
20062006
2007- // Check if the tag is non-empty.
2008- if length == 0 {
2007+ if ! hasTag {
20092008 yaml_parser_set_scanner_tag_error (parser , directive ,
20102009 start_mark , "did not find expected tag URI" )
20112010 return false
0 commit comments