Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix \r issue #142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions decode_bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (dec *Decoder) assertTrue() error {
}
case 3:
switch dec.data[dec.cursor] {
case ' ', '\b', '\t', '\n', ',', ']', '}':
case ' ', '\b', '\t', '\n', '\r', ',', ']', '}':
// dec.cursor--
return nil
default:
Expand Down Expand Up @@ -147,7 +147,7 @@ func (dec *Decoder) assertNull() error {
}
case 3:
switch dec.data[dec.cursor] {
case ' ', '\t', '\n', ',', ']', '}':
case ' ', '\t', '\n', '\r', ',', ']', '}':
// dec.cursor--
return nil
default:
Expand Down Expand Up @@ -184,7 +184,7 @@ func (dec *Decoder) assertFalse() error {
}
case 4:
switch dec.data[dec.cursor] {
case ' ', '\t', '\n', ',', ']', '}':
case ' ', '\t', '\n', '\r', ',', ']', '}':
// dec.cursor--
return nil
default:
Expand Down
16 changes: 8 additions & 8 deletions decode_number_int.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (dec *Decoder) getInt16() (int16, error) {
}
val := floatVal * float64(pow10uint64[pExp])
return int16(val), nil
case ' ', '\t', '\n', ',', ']', '}':
case ' ', '\t', '\n', '\r', ',', ']', '}':
dec.cursor = j
return dec.atoi16(start, end), nil
default:
Expand Down Expand Up @@ -507,7 +507,7 @@ func (dec *Decoder) getInt8() (int8, error) {
}
val := floatVal * float64(pow10uint64[pExp])
return int8(val), nil
case ' ', '\t', '\n', ',', ']', '}':
case ' ', '\t', '\n', '\r', ',', ']', '}':
dec.cursor = j
return dec.atoi8(start, end), nil
default:
Expand Down Expand Up @@ -548,7 +548,7 @@ func (dec *Decoder) getInt8WithExp(init int8) (int8, error) {
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
uintv := uint8(digits[dec.data[dec.cursor]])
exp = (exp << 3) + (exp << 1) + uintv
case ' ', '\t', '\n', '}', ',', ']':
case ' ', '\t', '\n', '\r', '}', ',', ']':
if exp+1 >= uint8(len(pow10uint64)) {
return 0, dec.raiseInvalidJSONErr(dec.cursor)
}
Expand Down Expand Up @@ -737,7 +737,7 @@ func (dec *Decoder) getInt32() (int32, error) {
}
val := floatVal * float64(pow10uint64[pExp])
return int32(val), nil
case ' ', '\t', '\n', ',', ']', '}':
case ' ', '\t', '\n', '\r', ',', ']', '}':
dec.cursor = j
return dec.atoi32(start, end), nil
default:
Expand Down Expand Up @@ -778,7 +778,7 @@ func (dec *Decoder) getInt32WithExp(init int32) (int32, error) {
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
uintv := uint32(digits[dec.data[dec.cursor]])
exp = (exp << 3) + (exp << 1) + uintv
case ' ', '\t', '\n', '}', ',', ']':
case ' ', '\t', '\n', '\r', '}', ',', ']':
if exp+1 >= uint32(len(pow10uint64)) {
return 0, dec.raiseInvalidJSONErr(dec.cursor)
}
Expand Down Expand Up @@ -920,7 +920,7 @@ func (dec *Decoder) getInt64() (int64, error) {
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
end = j
continue
case ' ', '\t', '\n', ',', '}', ']':
case ' ', '\t', '\n', '\r', ',', '}', ']':
dec.cursor = j
return dec.atoi64(start, end), nil
case '.':
Expand Down Expand Up @@ -971,7 +971,7 @@ func (dec *Decoder) getInt64() (int64, error) {
}
val := floatVal * float64(pow10uint64[pExp])
return int64(val), nil
case ' ', '\t', '\n', ',', ']', '}':
case ' ', '\t', '\n', '\r', ',', ']', '}':
dec.cursor = j
return dec.atoi64(start, end), nil
default:
Expand Down Expand Up @@ -1009,7 +1009,7 @@ func (dec *Decoder) getInt64WithExp(init int64) (int64, error) {
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
uintv := uint64(digits[dec.data[dec.cursor]])
exp = (exp << 3) + (exp << 1) + uintv
case ' ', '\t', '\n', '}', ',', ']':
case ' ', '\t', '\n', '\r', '}', ',', ']':
if exp+1 >= uint64(len(pow10uint64)) {
return 0, dec.raiseInvalidJSONErr(dec.cursor)
}
Expand Down