Comments (1)
I had the same panic
as well.
This will reproduce the crash.
package main
import (
"fmt"
"log"
"github.com/goccy/go-yaml"
)
func main() {
yml := `{"""":`
var v any
if err := yaml.Unmarshal([]byte(yml), &v); err != nil {
log.Fatal(err)
}
fmt.Printf("%#v\n", v)
}
For now, this will prevent panic.
(I don't know if the place to put the check is correct).
--- ../../goccy/go-yaml/parser/parser.go 2023-08-11 14:19:41.207313654 +0900
+++ vendor/github.com/goccy/go-yaml/parser/parser.go 2023-08-25 14:27:30.261698959 +0900
@@ -181,6 +181,12 @@
if err != nil {
return nil, errors.Wrapf(err, "failed to parse mapping 'value' node")
}
+
+ if value == nil {
+ nullToken := p.createNullToken(colonToken)
+ ctx.insertToken(ctx.idx, nullToken)
+ return ast.Null(nullToken), nil
+ }
return value, nil
}
from go-yaml.
Related Issues (20)
- Handling of Carriage Return (`\r`) in a double-quoted string differs from `gopkg.in/yaml.*.`
- Parser returns two documents instead of one
- Marshaler interfaces not checked against addressable non-pointers
- Diff to go-yaml/yaml HOT 1
- [Question] Is it possible to merge 2 yamls preserving anchors?
- ast.Merge error `cannot merge Mapping into Anchor`
- Expose useJSONMarshaler option in NewEncoder HOT 1
- Please verify 0b*** binary content and fallback to string
- Compile error HOT 1
- Multi-line strings don't work when there are curly braces
- comment after `-` causes subsequent queries to fail HOT 3
- 1.11.2 is mis-tagged HOT 1
- Get positional (Line / Column) information on a node HOT 6
- Add option to support mandatory field when decode
- Block with indent indicator is not parsed correctly
- Possibility of encoding tags
- Empty null value gets converted to "null" in token
- Empty null value with line comment causes seg fault
- Trailing new lines are added to literal strings HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-yaml.