Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Optparse passes incorrect options when casting to a Regexp #82

Closed
wants to merge 2 commits into from

2 participants

@msgerbush

In the optparse library, the wrong string is used to remove the i, m, and x options from the encoding options when casting an argument to a Regexp. It removes all characters that are NOT i, m, or x. This results in the wrong options being passed as the third argument of Regexp.new.

optparse.rb:1714: warning: encoding option is ignored - %s is thrown when valid options are passed as an argument, even though the options i, m, and x are correctly interpreted. Also, the encoding of a Regexp argument cannot be set.

@msgerbush

Should not have used regex syntax here, delete takes a string. This was deleting all characters in the intersection of o and the characters [,^,i,m,x, and ].

@shyouhei
Owner

Seems nobu merged this. Thank you.

@shyouhei shyouhei closed this
@bdwalton bdwalton referenced this pull request from a commit in bdwalton/ruby
@drbrain drbrain * lib/rubygems: Import RubyGems 1.8.7:
	  Added missing require for `gem uninstall --format-executable`.

	  The correct name of the executable being uninstalled is now displayed
	  with --format-executable.

	  Fixed `gem unpack uninstalled_gem` default version picker.

	  RubyGems no longer claims a nonexistent gem can be uninstalled.

	  `gem which` no longer claims directories are requirable files.

	  `gem cleanup` continues cleaning up gems if one can't be uninstalled
	  due to permissions.  Issue #82.

	  Gem repository directories are no longer created world-writable.
	  Patch by Sakuro OZAWA.  [Ruby 1.9 - Bug #4930]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
3434676
@voxik voxik referenced this pull request from a commit in voxik/ruby
@drbrain drbrain * lib/rubygems: Import RubyGems 1.8.7:
	  Added missing require for `gem uninstall --format-executable`.

	  The correct name of the executable being uninstalled is now displayed
	  with --format-executable.

	  Fixed `gem unpack uninstalled_gem` default version picker.

	  RubyGems no longer claims a nonexistent gem can be uninstalled.

	  `gem which` no longer claims directories are requirable files.

	  `gem cleanup` continues cleaning up gems if one can't be uninstalled
	  due to permissions.  Issue #82.

	  Gem repository directories are no longer created world-writable.
	  Patch by Sakuro OZAWA.  [Ruby 1.9 - Bug #4930]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
06d8902
@szuecs szuecs referenced this pull request from a commit in szuecs/ruby
@nobu nobu * lib/optparse.rb (Regexp): fix incorrect options when casting to
  a Regexp, and suppress encoding option warnings.
  ruby#82


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
de1e488
@tenderlove tenderlove referenced this pull request from a commit in tenderlove/ruby
@nobu nobu * lib/optparse.rb (Regexp): fix incorrect options when casting to
  a Regexp, and suppress encoding option warnings.
  ruby#82


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
8d0b236
@h4dex h4dex referenced this pull request from a commit in h4dex/ruby
@nobu nobu * lib/optparse.rb (Regexp): fix incorrect options when casting to
  a Regexp, and suppress encoding option warnings.
  ruby/ruby#82


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1543a9f
@h4dex h4dex referenced this pull request from a commit in h4dex/ruby
@nobu nobu * lib/optparse.rb (Regexp): fix incorrect options when casting to
  a Regexp, and suppress encoding option warnings.
  ruby/ruby#82


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@34316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2a1b0f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/optparse.rb
View
2  lib/optparse.rb
@@ -1709,7 +1709,7 @@ def environment(env = File.basename($0, '.*'))
f |= Regexp::IGNORECASE if /i/ =~ o
f |= Regexp::MULTILINE if /m/ =~ o
f |= Regexp::EXTENDED if /x/ =~ o
- k = o.delete("^imx")
+ k = o.delete("imx")
end
Regexp.new(s || all, f, k)
end
Something went wrong with that request. Please try again.