Land #6946 Fix a bug with OptPort validation when not req

bug/bundler_fix 4.12.6
Brian Patterson 2016-06-07 14:43:10 -05:00
commit 6d72b5b19f
No known key found for this signature in database
GPG Key ID: 79C4E4506D8A9C42
2 changed files with 5 additions and 3 deletions

View File

@ -15,15 +15,17 @@ class OptInt < OptBase
def normalize(value)
if value.to_s.match(/^0x[a-fA-F\d]+$/)
value.to_i(16)
else
elsif value.present?
value.to_i
else
nil
end
end
def valid?(value, check_empty: true)
return false if check_empty && empty_required_value?(value)
if value and not value.to_s.match(/^0x[0-9a-fA-F]+$|^-?\d+$/)
if value.present? and not value.to_s.match(/^0x[0-9a-fA-F]+$|^-?\d+$/)
return false
end

View File

@ -13,7 +13,7 @@ class OptPort < OptInt
end
def valid?(value, check_empty: true)
port = normalize(value)
port = normalize(value).to_i
super && port <= 65535 && port >= 0
end
end