Skip to content

Commit

Permalink
Change CBOR string validation error to SyntaxError
Browse files Browse the repository at this point in the history
Valid() returns SyntaxError instead of SemanticError when:
* indefinite length string chunks are not of the same type, or
* indefinite length string chunks are not definite length.

Closes: #56
  • Loading branch information
fxamacker committed Dec 3, 2019
1 parent e4fc93f commit acaec05
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions valid.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ func checkValidIndefinite(data []byte, off int, t cborType) (_ int, err error) {
}
if isByteOrTextString {
if t != nextType {
return 0, &SemanticError{"cbor: wrong element type " + nextType.String() + " for indefinite-length " + t.String()}
return 0, &SyntaxError{"cbor: wrong element type " + nextType.String() + " for indefinite-length " + t.String()}
}
if indefinite {
return 0, &SemanticError{"cbor: indefinite-length " + t.String() + " chunk is not definite-length"}
return 0, &SyntaxError{"cbor: indefinite-length " + t.String() + " chunk is not definite-length"}
}
}
}
Expand Down

0 comments on commit acaec05

Please sign in to comment.