From e9d030d5c5a831897d4ee3c2d4fdd2a2c8659976 Mon Sep 17 00:00:00 2001 From: Mark Dodwell Date: Thu, 24 Mar 2016 01:50:40 -0700 Subject: [PATCH] URI.parse "mailto:?subject=hi" as valid, per RFC6068 --- lib/uri/mailto.rb | 2 +- test/uri/test_mailto.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/uri/mailto.rb b/lib/uri/mailto.rb index 495f939..72b6bbb 100644 --- a/lib/uri/mailto.rb +++ b/lib/uri/mailto.rb @@ -143,7 +143,7 @@ def initialize(*arg) to, header = @opaque.split('?', 2) # allow semicolon as a addr-spec separator # http://support.microsoft.com/kb/820868 - unless /\A(?:[^@,;]+@[^@,;]+(?:\z|[,;]))*\z/ =~ to + if to.size > 0 && /\A(?:[^@,;]+@[^@,;]+(?:\z|[,;]))*\z/ !~ to raise InvalidComponentError, "unrecognised opaque part for mailtoURL: #{@opaque}" end diff --git a/test/uri/test_mailto.rb b/test/uri/test_mailto.rb index 4e3b042..9670456 100644 --- a/test/uri/test_mailto.rb +++ b/test/uri/test_mailto.rb @@ -97,6 +97,11 @@ def test_build ok[-1] << {:to => 'listman@example.com', :headers => [['subject', 'subscribe']]} ok[-1] << {:to => 'listman@example.com', :headers => [['subject', 'subscribe']]} + # mailto:?subject=hi + ok << ["mailto:?subject=hi"] + ok[-1] << {:to => '', :headers => [['subject', 'hi']]} + ok[-1] << {:to => '', :headers => [['subject', 'hi']]} + ok_all = ok.flatten.join("\0") # mailto:joe@example.com?cc=bob@example.com?body=hello ; WRONG! -- 2.5.0