-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v3 panics in some cases when marshalling unicode char in comments #538
Comments
Another example:
|
It wasn't the writing that was broken, but the reading. This should be fixed with 5308cda. Please drop me a note if you see related issues. |
Updated, unfortunately I still get the same error when reading
|
Works fine here and in play.golang.org: |
Ah but it doesn't work with Decoder/Encoder: |
It doesn't work with marshal/unmarshal if you specify a type: |
Okay I got the point: // ...
if parser.mark.index >= seen {
if len(text) == 0 {
start_mark = parser.mark
}
text = append(text, parser.buffer[parser.buffer_pos]) // ERROR!
}
skip(parser)
// ... In function parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) width: // Determine the width of the character.
func width(b byte) int {
// Don't replace these by a switch without first
// confirming that it is being inlined.
if b&0x80 == 0x00 {
return 1
}
if b&0xE0 == 0xC0 {
return 2
}
if b&0xF0 == 0xE0 {
return 3
}
if b&0xF8 == 0xF0 {
return 4
}
return 0
} The solution: width := width(parser.buffer[parser.buffer_pos])
text = append(text, parser.buffer[parser.buffer_pos:parser.buffer_pos+width]...) |
Thanks for investigating it. I've fixed a similar issue in 5308cda, and will use the same approach here. |
Okay, that same logic was applied to inline comments on 913338d. |
With yaml.v3, try this in go playground => get panic.
The text was updated successfully, but these errors were encountered: