go-yaml / yaml

YAML support for the Go language.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Valid YAML document (with escaped solidus) is not accepted by the parser

graywolf-at-work opened this issue · comments

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/oo

However 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 character

0: https://yaml.org/spec/1.2.2/#57-escaped-characters , [53]

Search for "slash" in the issues. There are already open issues about this.