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