send2vinnie / pugixml

Automatically exported from code.google.com/p/pugixml
0 stars 0 forks source link

Invalid comments are not escaped #234

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
- What steps will reproduce the problem?

Add a comment node containing "--" and write the document to a string.

- What is the expected output? What do you see instead?

The exact text added to the comment, including the "--" substring.

The "--" string is not allowed under the XML specification (see 
http://www.w3.org/TR/REC-xml/#sec-comments), preventing the document from being 
parsed by other XML libraries.

I prefer to see them escaped like character data, using the '−−' 
string in it's place.

Which version of pugixml are you using? On what operating system/compiler?

pugi 1.2, arch linux / gcc 4.9.0.

Original issue reported on code.google.com by LonieDa...@gmail.com on 16 Jul 2014 at 5:58

GoogleCodeExporter commented 9 years ago
The problem is that it seems to be literally impossible to write -- in a 
comment in any way.

CDATA has a similar problem that is handled by splitting the node that contains 
]]> sequence into two nodes. However, for comments this does not seem possible; 
comments do not support escape sequences so escaping -- is pointless.

The only possibility here I think is to write an extra whitespace, turning "--" 
into "- -".

Original comment by arseny.k...@gmail.com on 10 Aug 2014 at 9:56

GoogleCodeExporter commented 9 years ago

Original comment by arseny.k...@gmail.com on 25 Aug 2014 at 5:35

GoogleCodeExporter commented 9 years ago
Fixed in r1058.

Original comment by arseny.k...@gmail.com on 14 Oct 2014 at 4:26