OptionParser acceptable bugs
I have found a few bugs in OptionParser's accept feature:
Hexadecimal and binary numbers are not properly supported for Integer
OptionParser::DecimalInteger, OptionParser::OctalInteger and OptionParser::DecimalNumeric convert invalid input to 0 or nil instead of raising InvalidArgument.
The attached patch fixes the validation regular expression for handling binary and hexadecimal arguments and adds verification for DecimalInteger, OctalInteger and DecimalNumeric
Updated by drbrain (Eric Hodel) almost 7 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r42844.
Eric, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- lib/optparse.rb: The Integer acceptable now allows binary and hexadecimal numbers per the documentation. [ruby-trunk - Bug #8865]
DecimalInteger, OctalInteger, DecimalNumeric now validate their input
before converting to a number. [ruby-trunk - Bug #8865]
- test/optparse/test_acceptable.rb: Tests for the above, tests for all numeric acceptables for existing behavior.