File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -1189,6 +1189,7 @@ func unquoteBytes(s []byte) (t []byte, ok bool) {
11891189 if len (s ) < 2 || (s [0 ] != '"' && s [0 ] != '\'' ) || (s [len (s )- 1 ] != '"' && s [len (s )- 1 ] != '\'' ) {
11901190 return
11911191 }
1192+ orig := s
11921193 s = s [1 : len (s )- 1 ]
11931194
11941195 // Check for unusual characters. If there are none,
@@ -1287,7 +1288,7 @@ func unquoteBytes(s []byte) (t []byte, ok bool) {
12871288 }
12881289
12891290 // Quote, control characters are invalid.
1290- case s [0 ] == '"' && c == '"' , s [0 ] == '\'' && c == '\'' , c < ' ' :
1291+ case orig [0 ] == '"' && c == '"' , orig [0 ] == '\'' && c == '\'' , c < ' ' :
12911292 return
12921293
12931294 // ASCII
Original file line number Diff line number Diff line change @@ -130,3 +130,16 @@ func TestJSON5Decode(t *testing.T) {
130130 return nil
131131 })
132132}
133+
134+ // found with go-fuzz
135+ func TestQuotedQuote (t * testing.T ) {
136+ var v struct {
137+ E string
138+ }
139+ if err := Unmarshal ([]byte (`{e:"'"}` ), & v ); err != nil {
140+ t .Error (err )
141+ }
142+ if v .E != "'" {
143+ t .Errorf (`expected "'", got %q` , v .E )
144+ }
145+ }
You can’t perform that action at this time.
0 commit comments