Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ET cannot output CData containing "]]>" #17

Open
garthk opened this issue Feb 9, 2014 · 1 comment
Open

ET cannot output CData containing "]]>" #17

garthk opened this issue Feb 9, 2014 · 1 comment

Comments

@garthk
Copy link

garthk commented Feb 9, 2014

To reproduce with 0.1.6:

var et = require('elementtree'),
    root = et.Element('root'),
    cruelty = '<![CDATA[x]]>';
root.append(et.CData(cruelty));
console.log(et.tostring(root));

Buggy output:

<?xml version='1.0' encoding='utf-8'?>
<root><![CDATA[<![CDATA[x]]>]]></root>

xmllint complaint:

foo:2: parser error : Sequence ']]>' not allowed in content
<root><![CDATA[<![CDATA[x]]>]]></root>

Workaround:

root.append(et.CData(cruelty.replace(']]>', ']]]]><![CDATA[>'));

Output of workaround:

<?xml version='1.0' encoding='utf-8'?>
<root><![CDATA[<![CDATA[x]]]]><![CDATA[>]]></root>
@garthk
Copy link
Author

garthk commented Feb 9, 2014

If you use the workaround, I'd edit your package.json to lock elementtree at 0.1.6 by removing the ~ before 0.1.6:

"dependencies": {
  "elementtree": "0.1.6"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant