Skip to content

Commit

Permalink
Only allow valid version overrides in bin stubs
Browse files Browse the repository at this point in the history
This allows users to provide arguments like:

    rake _foo_

which cannot possibly match a version.  Previously RubyGems would give
a version parsing exception for such input.

Fixes #799
  • Loading branch information
drbrain committed Feb 3, 2014
1 parent 7515a3d commit 7ef96c5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions History.txt
Expand Up @@ -22,6 +22,8 @@ Bug fixes:
one or the other. Pull request #795 by zebardy.
* RubyGems can now use the bundler API against hosted gem servers in a
directory. Pull request #801 by Brian Fletcher.
* RubyGems bin stubs now ignore non-versions. This allows RubyGems bin stubs
to list file names like "_foo_". Issue #799 by Postmodern.

=== 2.2.1 / 2014-01-06

Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/installer.rb
Expand Up @@ -641,7 +641,7 @@ def app_script_text(bin_file_name)
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\\A_(.*)_\\z/
if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1) then
version = $1
ARGV.shift
end
Expand Down
2 changes: 1 addition & 1 deletion test/rubygems/test_gem_installer.rb
Expand Up @@ -41,7 +41,7 @@ def test_app_script_text
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\\A_(.*)_\\z/
if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1) then
version = $1
ARGV.shift
end
Expand Down

0 comments on commit 7ef96c5

Please sign in to comment.