Skip to content

Commit

Permalink
Allow parsing of single Null tokens from refmt
Browse files Browse the repository at this point in the history
For blocks that are simply "null":
 * dag-cbor: 0xf6
 * dag-json: null
  • Loading branch information
rvagg authored and warpfork committed Aug 10, 2021
1 parent e44329e commit 8ef23e5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion codec/dagcbor/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func unmarshal1(na ipld.NodeAssembler, tokSrc shared.TokenSource, gas *int, opti
if err != nil {
return err
}
if done && !tk.Type.IsValue() {
if done && !tk.Type.IsValue() && tk.Type != tok.TNull {
return fmt.Errorf("unexpected eof")
}
return unmarshal2(na, tokSrc, &tk, gas, options)
Expand Down
2 changes: 1 addition & 1 deletion codec/dagjson/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func Unmarshal(na ipld.NodeAssembler, tokSrc shared.TokenSource, options Unmarsh
if err != nil {
return err
}
if done && !st.tk[0].Type.IsValue() {
if done && !st.tk[0].Type.IsValue() && st.tk[0].Type != tok.TNull {
return fmt.Errorf("unexpected eof")
}
return st.unmarshal(na, tokSrc)
Expand Down

0 comments on commit 8ef23e5

Please sign in to comment.