[前][次][番号順一覧][スレッド一覧]

ruby-changes:44993

From: naruse <ko1@a...>
Date: Tue, 13 Dec 2016 00:24:33 +0900 (JST)
Subject: [ruby-changes:44993] naruse:r57066 (trunk): Use URI.decode_www_form_component [Bug #10774]

naruse	2016-12-13 00:24:28 +0900 (Tue, 13 Dec 2016)

  New Revision: 57066

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57066

  Log:
    Use URI.decode_www_form_component [Bug #10774]
    
    `parser` refered RFC2396_Parser, but it is separated.
    test is contributed by Dominik Menke

  Modified files:
    trunk/lib/uri/mailto.rb
    trunk/test/uri/test_mailto.rb
Index: lib/uri/mailto.rb
===================================================================
--- lib/uri/mailto.rb	(revision 57065)
+++ lib/uri/mailto.rb	(revision 57066)
@@ -267,18 +267,18 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/mailto.rb#L267
     #   # => "To: ruby-list@r...\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
 
Index: test/uri/test_mailto.rb
===================================================================
--- test/uri/test_mailto.rb	(revision 57065)
+++ test/uri/test_mailto.rb	(revision 57066)
@@ -187,6 +187,12 @@ class TestMailTo < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/uri/test_mailto.rb#L187
       u.select(:scheme, :host, :not_exist, :port)
     end
   end
+
+  def test_to_mailtext
+    u = URI.parse('mailto:ruby-list@r...?Subject=subscribe&cc=myaddr')
+    assert_equal "To: ruby-list@r...\nSubject: subscribe\nCc: myaddr\n\n\n",
+      u.to_mailtext
+  end
 end
 
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]