LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File CVE-2013-4287-4363.patch of Package ruby20 (Project devel:languages:ruby)

diff -Naur a/lib/rubygems/version.rb b/lib/rubygems/version.rb
--- a/lib/rubygems/version.rb	2013-10-21 16:53:11.442939806 +0200
+++ b/lib/rubygems/version.rb	2013-10-21 17:20:41.741034852 +0200
@@ -148,7 +148,7 @@
   # FIX: These are only used once, in .correct?. Do they deserve to be
   # constants?
   VERSION_PATTERN = '[0-9]+(\.[0-9a-zA-Z]+)*' # :nodoc:
-  ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})*\s*\z/ # :nodoc:
+  ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})?\s*\z/ # :nodoc:
 
   ##
   # A string representation of this Version.
diff -Naur a/test/rubygems/test_gem_requirement.rb b/test/rubygems/test_gem_requirement.rb
--- a/test/rubygems/test_gem_requirement.rb	2013-10-21 16:53:11.412939804 +0200
+++ b/test/rubygems/test_gem_requirement.rb	2013-10-21 17:21:57.796039232 +0200
@@ -47,18 +47,23 @@
   end
 
   def test_parse_bad
-    e = assert_raises Gem::Requirement::BadRequirementError do
-      Gem::Requirement.parse nil
+    [
+      nil,
+      '',
+      '! 1',
+      '= junk',
+      '1..2',
+    ].each do |bad|
+      e = assert_raises Gem::Requirement::BadRequirementError do
+        Gem::Requirement.parse bad
+      end
+      assert_equal 'Illformed requirement [""]', e.message
     end
 
-    assert_equal 'Illformed requirement [nil]', e.message
-
     e = assert_raises Gem::Requirement::BadRequirementError do
       Gem::Requirement.parse ""
     end
 
-    assert_equal 'Illformed requirement [""]', e.message
-
     assert_equal Gem::Requirement::BadRequirementError.superclass, ArgumentError
   end
 
diff -Naur a/test/rubygems/test_gem_version.rb b/test/rubygems/test_gem_version.rb
--- a/test/rubygems/test_gem_version.rb	2013-10-21 16:53:11.412939804 +0200
+++ b/test/rubygems/test_gem_version.rb	2013-10-21 17:20:41.741034852 +0200
@@ -67,12 +67,17 @@
   end
 
   def test_initialize_bad
-    ["junk", "1.0\n2.0"].each do |bad|
-      e = assert_raises ArgumentError do
+    %W[
+      junk
+      1.0\n2.0
+      1..2
+      1.2\ 3.4
+    ].each do |bad|
+      e = assert_raises ArgumentError, bad do
         Gem::Version.new bad
       end
 
-      assert_equal "Malformed version number string #{bad}", e.message
+      assert_equal "Malformed version number string #{bad}", e.message, bad
     end
   end