Bug #9277
closedREXML fails to parse comments with multiple dashes ('-') in them
Description
=begin
REXML cannot handle multiple dashes in a comment:
require 'rexml/document'
REXML::Document.new('')
=end
=begin
REXML::ParseException: #<REXML::ParseException: Malformed comment
Line: 1
Position: 24
Last 80 unconsumed characters:
/Users/foo/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rexml/parsers/baseparser.rb:351:in pull_event' /Users/foo/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rexml/parsers/baseparser.rb:183:in
pull'
/Users/foo/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rexml/parsers/treeparser.rb:22:in parse' /Users/foo/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rexml/document.rb:283:in
build'
/Users/foo/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rexml/document.rb:43:in `initialize'
...
Malformed comment
Line: 1
Position: 24
Last 80 unconsumed characters:
Line: 1
Position: 24
Last 80 unconsumed characters:
from /Users/foo/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rexml/parsers/treeparser.rb:95:in `rescue in parse'
from /Users/foo/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rexml/parsers/treeparser.rb:20:in `parse'
from /Users/foo/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rexml/document.rb:283:in `build'
from /Users/foo/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rexml/document.rb:43:in `initialize'
<extra stack trace ommitted>
=end
Updated by zzak (zzak _) about 11 years ago
- Category set to lib
- Status changed from Open to Assigned
- Assignee set to kou (Kouhei Sutou)
Updated by mame (Yusuke Endoh) about 11 years ago
As I recall correctly, the XML spec does not allow "--" in a comment.
http://en.wikipedia.org/wiki/XML#Comments
The string "--" (double-hyphen) is not allowed inside comments
--
Yusuke Endoh mame@tsg.ne.jp
Updated by duerst (Martin Dürst) about 11 years ago
- Status changed from Assigned to Rejected
- Assignee deleted (
kou (Kouhei Sutou))
mame (Yusuke Endoh) wrote:
As I recall correctly, the XML spec does not allow "--" in a comment.
Yes indeed. See http://www.w3.org/TR/xml/#sec-comments:
"For compatibility, the string " -- " (double-hyphen) MUST NOT occur within comments."
As for the phrase "for compatibility", this is what the spec says (http://www.w3.org/TR/xml/#dt-compat):
"for compatibility [Definition: Marks a sentence describing a feature of XML included solely to ensure that XML remains compatible with SGML.]"
So I have rejected this bug.