Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/uri/mailto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,18 @@ def to_s
# # => "To: ruby-list@ruby-lang.org\nSubject: subscribe\nCc: myaddr\n\n\n"
#
def to_mailtext
to = URI.decode_www_form_component(@to)
to = URI.decode_uri_component(@to)
head = ''
body = ''
@headers.each do |x|
case x[0]
when 'body'
body = URI.decode_www_form_component(x[1])
body = URI.decode_uri_component(x[1])
when 'to'
to << ', ' + URI.decode_www_form_component(x[1])
to << ', ' + URI.decode_uri_component(x[1])
else
head << URI.decode_www_form_component(x[0]).capitalize + ': ' +
URI.decode_www_form_component(x[1]) + "\n"
head << URI.decode_uri_component(x[0]).capitalize + ': ' +
URI.decode_uri_component(x[1]) + "\n"
end
end

Expand Down
8 changes: 8 additions & 0 deletions test/uri/test_mailto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ def uri_to_ary(uri)
uri.class.component.collect {|c| uri.send(c)}
end


def test_to_mailtext_preserves_literal_plus
uri = URI.parse("mailto:a+b@example.test?subject=a+b&body=x+y")

assert_equal("To: a+b@example.test\nSubject: a+b\n\nx+y\n", uri.to_mailtext)
assert_equal(uri.to_mailtext, uri.to_rfc822text)
end

def test_build
ok = []
bad = []
Expand Down