Skip to content

Commit

Permalink
fix: validate tag before emitting
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Apr 11, 2023
1 parent 29cddc6 commit bb7e016
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion emitterc.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ package yaml
import (
"bytes"
"fmt"
"unicode/utf8"
)

// Flush the buffer if needed.
Expand Down Expand Up @@ -1583,7 +1584,11 @@ func yaml_emitter_write_tag_content(emitter *yaml_emitter_t, value []byte, allow
return false
}
} else {
w := width(value[i])
r, w := utf8.DecodeRune(value[i:])
if r == utf8.RuneError {
yaml_emitter_set_emitter_error(emitter, fmt.Sprintf("invalid UTF-8 in tag %+q", value))
return false
}
for k := 0; k < w; k++ {
octet := value[i]
i++
Expand Down

0 comments on commit bb7e016

Please sign in to comment.