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

ruby-changes:46437

From: kou <ko1@a...>
Date: Wed, 3 May 2017 21:25:23 +0900 (JST)
Subject: [ruby-changes:46437] kou:r58552 (trunk): rss: Accept empty text element as valid element

kou	2017-05-03 21:25:17 +0900 (Wed, 03 May 2017)

  New Revision: 58552

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

  Log:
    rss: Accept empty text element as valid element
    
    Parser has been accepted it but XML serializer wasn't accepted.
    
    Reported by stefano frabetti. Thanks!!!
    
    [ruby-core:80965] [Bug #13531]

  Modified files:
    trunk/lib/rss/rss.rb
    trunk/test/rss/test_to_s.rb
Index: lib/rss/rss.rb
===================================================================
--- lib/rss/rss.rb	(revision 58551)
+++ lib/rss/rss.rb	(revision 58552)
@@ -957,7 +957,7 @@ EOC https://github.com/ruby/ruby/blob/trunk/lib/rss/rss.rb#L957
             children = child
             children.any? {|c| c.have_required_elements?}
           else
-            !child.to_s.empty?
+            not child.nil?
           end
         else
           true
Index: test/rss/test_to_s.rb
===================================================================
--- test/rss/test_to_s.rb	(revision 58551)
+++ test/rss/test_to_s.rb	(revision 58552)
@@ -109,6 +109,30 @@ module RSS https://github.com/ruby/ruby/blob/trunk/test/rss/test_to_s.rb#L109
                    '[ruby-core:70667] [Bug #11509]')
     end
 
+    def test_20_empty_text
+      title = "Blog entries"
+      link = "http://blog.example.com/"
+      description = ""
+      rss = RSS::Maker.make("2.0") do |maker|
+        maker.channel.title = title
+        maker.channel.link = link
+        maker.channel.description = description
+      end
+
+      parsed_rss = RSS::Parser.parse(rss.to_s)
+      assert_equal({
+                     title: title,
+                     link: link,
+                     description: description,
+                   },
+                   {
+                     title: parsed_rss.channel.title,
+                     link: parsed_rss.channel.link,
+                     description: parsed_rss.channel.description,
+                   },
+                   "[ruby-core:80965] [Bug #13531]")
+    end
+
     private
     def setup_xml_declaration_info
       @version = "1.0"

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

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