Bugs item #25677, was opened at 2009-04-25 01:09
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=575&aid=25677&group_id=126

Category: other
Group: v1.3.x
>Status: Closed
>Resolution: Accepted
Priority: 3
Submitted By: Mike Burrows (asplake)
>Assigned to: Eric Hodel (drbrain)
Summary: Gem::Specification#validate fails if homepage is unspecified

Initial Comment:
rubygems/specification.rb:886:
    unless homepage.empty? or homepage =~ /\A[a-z][a-z\d+.-]*:/i then

The above line fails with
  undefined method `empty?' for nil:NilClass
if homepage is nil, and the helpful "no #{attribute} specified" warning a few 
lines later is never reached.

Perhaps someone assumed that everyone has #empty? defined on NilClass?  I 
worked around this problem (and identified my missing homepage setting) by 
doing just that in my Rakefile.

Thank you for an otherwise wonderful thing!
Mike


RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.2
  - RUBY VERSION: 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
  - RUBY EXECUTABLE: 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-9
  - GEM PATHS:
     - /Library/Ruby/Gems/1.8
     - /Users/asplake/.gem/ruby/1.8
     - 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/


----------------------------------------------------------------------

>Comment By: Eric Hodel (drbrain)
Date: 2009-05-01 16:55

Message:
I decided on a simpler change of adding a nil check to homepage.  Fixed.

----------------------------------------------------------------------

Comment By: Mike Burrows (asplake)
Date: 2009-04-30 22:26

Message:
Thanks, looks to me like the right change to make.  URI.parse can be improved 
independently (via sporkmonger's Addressable::URI perhaps).

----------------------------------------------------------------------

Comment By: Daniel Berger (djberg96)
Date: 2009-04-30 19:07

Message:
BTW, the downside of my suggested patch is that URI.parse appears to be pretty 
liberal with what's legal and what isn't (including empty strings), compared to 
the current regex.

Dan

----------------------------------------------------------------------

Comment By: Daniel Berger (djberg96)
Date: 2009-04-30 16:00

Message:
Proposed change:

--- specification.rb    2009-04-30 16:48:09.000000000 -0600
+++ specification.new   2009-04-30 16:47:56.000000000 -0600
@@ -883,9 +883,13 @@
             '"FIXME" or "TODO" is not a summary'
     end
 
-    unless homepage.empty? or homepage =~ /\A[a-z][a-z\d+.-]*:/i then
-      raise Gem::InvalidSpecificationException,
-            "\#{homepage}\ is not a URI"
+    if homepage
+      begin
+        URI.parse(homepage)
+      rescue URI::InvalidURIError
+        raise Gem::InvalidSpecificationException,
+          "#{homepage} is not a valid URI"
+      end
     end
 
     # Warnings

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=575&aid=25677&group_id=126
_______________________________________________
Rubygems-developers mailing list
http://rubyforge.org/projects/rubygems
Rubygems-developers@rubyforge.org
http://rubyforge.org/mailman/listinfo/rubygems-developers

Reply via email to