ruby-changes:37173
From: duerst <ko1@a...>
Date: Wed, 14 Jan 2015 18:06:35 +0900 (JST)
Subject: [ruby-changes:37173] duerst:r49254 (trunk): * lib/uri/mailto.rb: raising URI::InvalidComponentError instead
duerst 2015-01-14 18:06:13 +0900 (Wed, 14 Jan 2015) New Revision: 49254 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49254 Log: * lib/uri/mailto.rb: raising URI::InvalidComponentError instead of failing with undefined method `split' for nil:NilClass for mailto: URIs without opaque part. [Bug #10738] * test/uri/testuri.rb: Test for above Modified files: trunk/ChangeLog trunk/lib/uri/mailto.rb trunk/test/uri/test_mailto.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 49253) +++ ChangeLog (revision 49254) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Jan 14 18:06:06 2015 Martin Duerst <duerst@i...> + + * lib/uri/mailto.rb: raising URI::InvalidComponentError instead + of failing with undefined method `split' for nil:NilClass for + mailto: URIs without opaque part. [Bug #10738] + * test/uri/testuri.rb: Test for above + Wed Jan 14 16:45:24 2015 Nobuyoshi Nakada <nobu@r...> * tool/downloader.rb (RubyGems.download): verify downloaded gem Index: lib/uri/mailto.rb =================================================================== --- lib/uri/mailto.rb (revision 49253) +++ lib/uri/mailto.rb (revision 49254) @@ -135,6 +135,10 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/mailto.rb#L135 @to = nil @headers = [] + unless @opaque + raise InvalidComponentError, + "missing opaque part for mailto URL" + end to, header = @opaque.split('?', 2) # allow semicolon as a addr-spec separator # http://support.microsoft.com/kb/820868 Index: test/uri/test_mailto.rb =================================================================== --- test/uri/test_mailto.rb (revision 49253) +++ test/uri/test_mailto.rb (revision 49254) @@ -104,6 +104,9 @@ class TestMailTo < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/uri/test_mailto.rb#L104 # mailto:javascript:alert() bad << ["javascript:alert()", []] + # mailto:/example.com/ ; WRONG, not a mail address + bad << ["/example.com/", []] + # '=' which is in hname or hvalue is wrong. bad << ["foo@e...?subject=1+1=2", []] -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/