summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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