Project

General

Profile

Bug #8865

OptionParser acceptable bugs

Added by drbrain (Eric Hodel) almost 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
-
[ruby-core:57024]

Description

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


Files

optparse.rb.accept.patch (1.63 KB) optparse.rb.accept.patch drbrain (Eric Hodel), 09/05/2013 06:00 AM
optparse.rb.accept.2.patch (6.85 KB) optparse.rb.accept.2.patch drbrain (Eric Hodel), 09/05/2013 09:20 AM
optparse.rb.accept.3.patch (7.77 KB) optparse.rb.accept.3.patch drbrain (Eric Hodel), 09/05/2013 09:47 AM

Also available in: Atom PDF