summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-26 14:17:24 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-26 14:17:24 +0000
commit75a138732efe3c19e99154eb3f9795d5f93c26ec (patch)
tree0a7da0e7e630d1bde756d47e1f6d918ab1d07c10
parent41f864faab6f1cdd8ad7e88c9c89fea200d030d2 (diff)
* lib/rexml/parsers/streamparser.rb
(REXML::Parsers::StreamParser#parse): Add "entity" event support to listener. [Bug #8689] [ruby-dev:47542] Reported by Ippei Obayashi. * test/rexml/test_stream.rb (StreamTester#entity): Add a test for the above case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog9
-rw-r--r--lib/rexml/parsers/streamparser.rb4
-rw-r--r--test/rexml/test_stream.rb23
3 files changed, 36 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index f735413..0185c30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Fri Jul 26 23:14:31 2013 Kouhei Sutou <kou@cozmixng.org>
+
+ * lib/rexml/parsers/streamparser.rb
+ (REXML::Parsers::StreamParser#parse): Add "entity" event support to
+ listener. [Bug #8689] [ruby-dev:47542]
+ Reported by Ippei Obayashi.
+ * test/rexml/test_stream.rb (StreamTester#entity): Add a test for
+ the above case.
+
Fri Jul 26 23:05:27 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (parser_yylex): separate numeric literal from succeeding
diff --git a/lib/rexml/parsers/streamparser.rb b/lib/rexml/parsers/streamparser.rb
index 073fcc2..9456ea8 100644
--- a/lib/rexml/parsers/streamparser.rb
+++ b/lib/rexml/parsers/streamparser.rb
@@ -38,6 +38,10 @@ module REXML
@listener.send( event[0].to_s, *event[1..-1] )
when :entitydecl, :notationdecl
@listener.send( event[0].to_s, event[1..-1] )
+ when :externalentity
+ entity_reference = event[1]
+ content = entity_reference.gsub(/\A%|;\z/, "")
+ @listener.entity(content)
end
end
end
diff --git a/test/rexml/test_stream.rb b/test/rexml/test_stream.rb
index 3f876ae..0ae1bc6 100644
--- a/test/rexml/test_stream.rb
+++ b/test/rexml/test_stream.rb
@@ -63,6 +63,29 @@ class StreamTester < Test::Unit::TestCase
assert( listener.events[:elementdecl] )
assert( listener.events[:notationdecl] )
end
+
+ def test_entity
+ listener = MyListener.new
+ class << listener
+ attr_accessor :entities
+ def entity(content)
+ @entities << content
+ end
+ end
+ listener.entities = []
+
+ source = StringIO.new(<<-XML)
+<!DOCTYPE root [
+<!ENTITY % ISOLat2
+ SYSTEM "http://www.xml.com/iso/isolat2-xml.entities" >
+%ISOLat2;
+]>
+<root/>
+ XML
+ REXML::Document.parse_stream(source, listener)
+
+ assert_equal(["ISOLat2"], listener.entities)
+ end
end