Skip to content

Commit

Permalink
Cause 123. to fail when mimicing JSON gem
Browse files Browse the repository at this point in the history
  • Loading branch information
ohler55 committed Nov 29, 2018
1 parent b7b21da commit fa6302f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# CHANGELOG

## 3.7.2 - 2018-11-29

- More tolerant float parsing to allow `123.`.

- Parse exceptions raised by user code now preserve the message content of the exception.

## 3.7.1 - 2018-11-09

- Updated to support TruffleRuby.

## 3.7.0 - 2018-10-29

- Thanks to Ziaw for adding a integer range where integers outside that range are written as strings.

## 3.6.13 - 2018-10-25

- Fixed issue where exceptions were not being cleared on parsing.

- Added addition unicode dump error information.

## 3.6.12 - 2018-10-16
Expand All @@ -35,7 +41,7 @@
## 3.6.8 - 2018-09-08

- Stopped setting the default options when optimze rails is called as the documentaiton has indicated.

- In custom mode `Date` and `DateTime` instances default to use the `:time_format` option is the `:create_additions` option is false.

## 3.6.7 - 2018-08-26
Expand Down
13 changes: 7 additions & 6 deletions ext/oj/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,14 @@ read_num(ParseInfo pi) {
}
if ('.' == *pi->cur) {
pi->cur++;
// A trailing . is not a valid decimal but if encountered allow it.
#if 0
if (*pi->cur < '0' || '9' < *pi->cur) {
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "not a number");
return;
// A trailing . is not a valid decimal but if encountered allow it
// except when mimicing the JSON gem.
if (CompatMode == pi->options.mode) {
if (*pi->cur < '0' || '9' < *pi->cur) {
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "not a number");
return;
}
}
#endif
for (; '0' <= *pi->cur && *pi->cur <= '9'; pi->cur++) {
int d = (*pi->cur - '0');

Expand Down
11 changes: 6 additions & 5 deletions ext/oj/sparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,13 @@ read_num(ParseInfo pi) {
}
if ('.' == c) {
c = reader_get(&pi->rd);
// A trailing . is not a valid decimal but if encountered allow it.
#if 0
if (c < '0' || '9' < c) {
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "not a number");
// A trailing . is not a valid decimal but if encountered allow it
// except when mimicing the JSON gem.
if (CompatMode == pi->options.mode) {
if (c < '0' || '9' < c) {
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "not a number");
}
}
#endif
for (; '0' <= c && c <= '9'; c = reader_get(&pi->rd)) {
int d = (c - '0');

Expand Down
2 changes: 1 addition & 1 deletion lib/oj/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

module Oj
# Current version of the module.
VERSION = '3.7.1'
VERSION = '3.7.2'
end

0 comments on commit fa6302f

Please sign in to comment.