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

ruby-changes:28432

From: kou <ko1@a...>
Date: Fri, 26 Apr 2013 23:36:41 +0900 (JST)
Subject: [ruby-changes:28432] kou:r40484 (trunk): * lib/rexml/text.rb (REXML::Text.normalize): Fix a bug that all

kou	2013-04-26 23:36:30 +0900 (Fri, 26 Apr 2013)

  New Revision: 40484

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40484

  Log:
    * lib/rexml/text.rb (REXML::Text.normalize): Fix a bug that all
      entity filters are ignored. [ruby-dev:47278] [Bug #8302]
      Patch by Ippei Obayashi. Thanks!!!
    * test/rexml/test_entity.rb (EntityTester#test_entity_filter): Add
      a test of the above change.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rexml/text.rb
    trunk/test/rexml/test_entity.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40483)
+++ ChangeLog	(revision 40484)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Apr 26 23:34:59 2013  Kouhei Sutou  <kou@c...>
+
+	* lib/rexml/text.rb (REXML::Text.normalize): Fix a bug that all
+	  entity filters are ignored. [ruby-dev:47278] [Bug #8302]
+	  Patch by Ippei Obayashi. Thanks!!!
+	* test/rexml/test_entity.rb (EntityTester#test_entity_filter): Add
+	  a test of the above change.
+
 Fri Apr 26 22:53:55 2013  Kouhei Sutou  <kou@c...>
 
 	* lib/rexml/element.rb (REXML::Attributes#to_a): Support
Index: lib/rexml/text.rb
===================================================================
--- lib/rexml/text.rb	(revision 40483)
+++ lib/rexml/text.rb	(revision 40484)
@@ -368,7 +368,7 @@ module REXML https://github.com/ruby/ruby/blob/trunk/lib/rexml/text.rb#L368
         doctype.entities.each_value do |entity|
           copy = copy.gsub( entity.value,
             "&#{entity.name};" ) if entity.value and
-              not( entity_filter and entity_filter.include?(entity) )
+              not( entity_filter and entity_filter.include?(entity.name) )
         end
       else
         # Replace all ampersands that aren't part of an entity
Index: test/rexml/test_entity.rb
===================================================================
--- test/rexml/test_entity.rb	(revision 40483)
+++ test/rexml/test_entity.rb	(revision 40484)
@@ -164,4 +164,24 @@ class EntityTester < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/rexml/test_entity.rb#L164
   def test_single_pass_unnormalization # ticket 123
     assert_equal '&amp;&', REXML::Text::unnormalize('&#38;amp;&amp;')
   end
+
+  def test_entity_filter
+    document = REXML::Document.new(<<-XML)
+<!DOCTYPE root [
+<!ENTITY copy "(c)">
+<!ENTITY release-year "2013">
+]>
+<root/>
+XML
+    respect_whitespace = false
+    parent = document.root
+    raw = false
+    entity_filter = ["copy"]
+    assert_equal("(c) &release-year;",
+                 REXML::Text.new("(c) 2013",
+                                 respect_whitespace,
+                                 parent,
+                                 raw,
+                                 entity_filter).to_s)
+  end
 end

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

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