ruby-changes:61575
From: Mark <ko1@a...>
Date: Fri, 5 Jun 2020 11:50:19 +0900 (JST)
Subject: [ruby-changes:61575] f245976386 (master): [ruby/psych] Fix ArgumentError with leading and trailing underscores in number strings.
https://git.ruby-lang.org/ruby.git/commit/?id=f245976386 From f2459763862fa2eef6929557a87763fe5ff5c470 Mon Sep 17 00:00:00 2001 From: Mark Thorn <mcthorn@g...> Date: Tue, 3 Mar 2020 10:03:28 -0800 Subject: [ruby/psych] Fix ArgumentError with leading and trailing underscores in number strings. https://github.com/ruby/psych/commit/ac2d2c9b1b diff --git a/ext/psych/lib/psych/scalar_scanner.rb b/ext/psych/lib/psych/scalar_scanner.rb index cea2a45..d565a33 100644 --- a/ext/psych/lib/psych/scalar_scanner.rb +++ b/ext/psych/lib/psych/scalar_scanner.rb @@ -101,7 +101,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/scalar_scanner.rb#L101 ### # Parse and return an int from +string+ def parse_int string - Integer(string.gsub(/[,]/, '')) + Integer(string.gsub(/[,_]/, '')) end ### diff --git a/test/psych/test_scalar_scanner.rb b/test/psych/test_scalar_scanner.rb index d12a905..1bd6488 100644 --- a/test/psych/test_scalar_scanner.rb +++ b/test/psych/test_scalar_scanner.rb @@ -120,6 +120,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/test/psych/test_scalar_scanner.rb#L120 assert_equal 123_456_789, ss.tokenize('123_456_789') assert_equal 123_456_789, ss.tokenize('123,456,789') assert_equal 123_456_789, ss.tokenize('1_2,3,4_5,6_789') + assert_equal 123_456_789, ss.tokenize('1_2,3,4_5,6_789_') assert_equal 0b010101010, ss.tokenize('0b010101010') assert_equal 0b010101010, ss.tokenize('0b0,1_0,1_,0,1_01,0') @@ -129,6 +130,8 @@ module Psych https://github.com/ruby/ruby/blob/trunk/test/psych/test_scalar_scanner.rb#L130 assert_equal 0x123456789abcdef, ss.tokenize('0x123456789abcdef') assert_equal 0x123456789abcdef, ss.tokenize('0x12_,34,_56,_789abcdef') + assert_equal 0x123456789abcdef, ss.tokenize('0x_12_,34,_56,_789abcdef') + assert_equal 0x123456789abcdef, ss.tokenize('0x12_,34,_56,_789abcdef__') end end end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/