summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS6
-rw-r--r--lib/rexml/parsers/sax2parser.rb2
-rw-r--r--lib/rexml/sax2listener.rb2
-rw-r--r--test/rexml/parser/test_sax2.rb31
4 files changed, 37 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index f791363235..a3b560962a 100644
--- a/NEWS
+++ b/NEWS
@@ -182,6 +182,12 @@ with all sufficient information, see the ChangeLog file.
* REXML::Parsers::StreamParser
* Supports "entity" event.
+* REXML::Parsers::SAX2Parser
+ * Fixes wrong number of arguments of entitydecl event. Document of the event
+ says "an array of the entity declaration" but implemenation passes two
+ or more arguments. It is an implementation bug but it breaks backword
+ compatibility.
+
* REXML::Text
* REXML::Text#<< supports method chain like 'text << "XXX" << "YYY"'.
* REXML::Text#<< supports not "raw" mode.
diff --git a/lib/rexml/parsers/sax2parser.rb b/lib/rexml/parsers/sax2parser.rb
index 0661af37aa..d73daf7036 100644
--- a/lib/rexml/parsers/sax2parser.rb
+++ b/lib/rexml/parsers/sax2parser.rb
@@ -177,7 +177,7 @@ module REXML
handle( :characters, copy )
when :entitydecl
@entities[ event[1] ] = event[2] if event.size == 3
- handle( *event )
+ handle( event[0], event[1..-1] )
when :processing_instruction, :comment, :attlistdecl,
:elementdecl, :cdata, :notationdecl, :xmldecl
handle( *event )
diff --git a/lib/rexml/sax2listener.rb b/lib/rexml/sax2listener.rb
index 6830e4483a..ac530d2eed 100644
--- a/lib/rexml/sax2listener.rb
+++ b/lib/rexml/sax2listener.rb
@@ -70,7 +70,7 @@ module REXML
# ["open-hatch", "PUBLIC", "\"-//Textuality//TEXT Standard open-hatch boilerplate//EN\"", "\"http://www.textuality.com/boilerplate/OpenHatch.xml\""]
# <!ENTITY hatch-pic SYSTEM "../grafix/OpenHatch.gif" NDATA gif>
# ["hatch-pic", "SYSTEM", "\"../grafix/OpenHatch.gif\"", "\n\t\t\t\t\t\t\tNDATA gif", "gif"]
- def entitydecl name, decl
+ def entitydecl declaration
end
# <!NOTATION ...>
def notationdecl content
diff --git a/test/rexml/parser/test_sax2.rb b/test/rexml/parser/test_sax2.rb
index d808899dd2..f1e64121af 100644
--- a/test/rexml/parser/test_sax2.rb
+++ b/test/rexml/parser/test_sax2.rb
@@ -22,9 +22,9 @@ class TestSAX2Parser < Test::Unit::TestCase
@entity_declarations = []
end
- def entitydecl(*args)
+ def entitydecl(declaration)
super
- @entity_declarations << args
+ @entity_declarations << declaration
end
end
@@ -51,6 +51,33 @@ class TestSAX2Parser < Test::Unit::TestCase
INTERNAL_SUBSET
end
end
+
+ class TestExternlID < self
+ class TestSystem < self
+ def test_without_ndata
+ declaration = [
+ "name",
+ "SYSTEM", "system-literal",
+ ]
+ assert_equal([declaration],
+ parse(<<-INTERNAL_SUBSET))
+<!ENTITY name SYSTEM "system-literal">
+ INTERNAL_SUBSET
+ end
+ end
+
+ class TestPublic < self
+ def test_without_ndata
+ declaration = [
+ "name",
+ "PUBLIC", "public-literal", "system-literal",
+ ]
+ assert_equal([declaration], parse(<<-INTERNAL_SUBSET))
+<!ENTITY name PUBLIC "public-literal" "system-literal">
+ INTERNAL_SUBSET
+ end
+ end
+ end
end
end
end