mirror of
https://github.com/json-iterator/go.git
synced 2025-02-07 19:30:06 +02:00
control character in string is invalid
This commit is contained in:
parent
a447a8f797
commit
c38e47d169
@ -2,6 +2,7 @@ package jsoniter
|
||||
|
||||
import (
|
||||
"unicode/utf16"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ReadString read string from iterator
|
||||
@ -16,6 +17,10 @@ func (iter *Iterator) ReadString() (ret string) {
|
||||
return ret
|
||||
} else if c == '\\' {
|
||||
break
|
||||
} else if c < ' ' {
|
||||
iter.ReportError("ReadString",
|
||||
fmt.Sprintf(`invalid control character found: %d`, c))
|
||||
return
|
||||
}
|
||||
}
|
||||
return iter.readStringSlowPath()
|
||||
|
@ -19,7 +19,10 @@ func Test_read_string(t *testing.T) {
|
||||
`"\"`,
|
||||
`"\\\"`,
|
||||
"\"\n\"",
|
||||
`navy`,
|
||||
}
|
||||
for i :=0; i < 32; i++ {
|
||||
// control characters are invalid
|
||||
badInputs = append(badInputs, string([]byte{'"', byte(i), '"'}))
|
||||
}
|
||||
|
||||
for _, input := range badInputs {
|
||||
|
Loading…
x
Reference in New Issue
Block a user