Valid YAML document (with escaped solidus) is not accepted by the parser
Author: graywolf-at-workCreated May 26, 2023Updated Feb 10, 2025
Hello,
today I hit a bug when trying to parse a YAML document using this library. Reproduction can be simplified to this document:
"f\/oo"That is valid document[0], and for example ruby parses it just fine:
$ ruby -ryaml -e 'puts YAML.load %q{"f\\/oo"}'
f/ooHowever this library does not accept it:
package main
import (
"gopkg.in/yaml.v3"
)
func main() {
t := ""
if err := yaml.Unmarshal([]byte(`"f\/oo"`), &t); err != nil {
panic(err)
}
}Error:
panic: yaml: found unknown escape character0: https://yaml.org/spec/1.2.2/#57-escaped-characters , [53]
Source: go-yaml/yaml