зеркало из https://github.com/github/ruby.git
Use URI.decode_www_form_component [Bug #10774]
`parser` refered RFC2396_Parser, but it is separated. test is contributed by Dominik Menke git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
31f17f880e
Коммит
6c0aece53d
|
@ -267,18 +267,18 @@ module URI
|
|||
# # => "To: ruby-list@ruby-lang.org\nSubject: subscribe\nCc: myaddr\n\n\n"
|
||||
#
|
||||
def to_mailtext
|
||||
to = parser.unescape(@to)
|
||||
to = URI.decode_www_form_component(@to)
|
||||
head = ''
|
||||
body = ''
|
||||
@headers.each do |x|
|
||||
case x[0]
|
||||
when 'body'
|
||||
body = parser.unescape(x[1])
|
||||
body = URI.decode_www_form_component(x[1])
|
||||
when 'to'
|
||||
to << ', ' + parser.unescape(x[1])
|
||||
to << ', ' + URI.decode_www_form_component(x[1])
|
||||
else
|
||||
head << parser.unescape(x[0]).capitalize + ': ' +
|
||||
parser.unescape(x[1]) + "\n"
|
||||
head << URI.decode_www_form_component(x[0]).capitalize + ': ' +
|
||||
URI.decode_www_form_component(x[1]) + "\n"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -187,6 +187,12 @@ class TestMailTo < Test::Unit::TestCase
|
|||
u.select(:scheme, :host, :not_exist, :port)
|
||||
end
|
||||
end
|
||||
|
||||
def test_to_mailtext
|
||||
u = URI.parse('mailto:ruby-list@ruby-lang.org?Subject=subscribe&cc=myaddr')
|
||||
assert_equal "To: ruby-list@ruby-lang.org\nSubject: subscribe\nCc: myaddr\n\n\n",
|
||||
u.to_mailtext
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче