Skip to content

Commit ab631b3

Browse files
committed
Another Ruby 2.6 BigDecimal compatibility issue
This patch modifies XmlMini::Parsing["decimal"] to handle a string that contains an invalid number. Since [ruby/ruby@a0e438c#diff-6b866d482baf2bdfd8433893fb1f6d36R144](ruby/ruby@a0e438c#diff-6b866d482baf2bdfd8433893fb1f6d36R144) this case raises an `ArgumentError`. `String.to_f` returns 0.0 if there is not a valid number at the start of the argument, so current behavior is conserved. See https://travis-ci.org/rails/rails/jobs/463180341#L6264 Related: rails#34600, rails#34601
1 parent 609c58b commit ab631b3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

activesupport/lib/active_support/xml_mini.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def content_type
7171
begin
7272
BigDecimal(number)
7373
rescue ArgumentError
74-
BigDecimal("0")
74+
BigDecimal(number.to_f.to_s)
7575
end
7676
else
7777
BigDecimal(number)

0 commit comments

Comments
 (0)