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

Write CDATA node with a redundant "]]" #216

Closed
slzhu opened this issue Mar 2, 2018 · 3 comments
Closed

Write CDATA node with a redundant "]]" #216

slzhu opened this issue Mar 2, 2018 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@slzhu
Copy link

slzhu commented Mar 2, 2018

In the source code(mxml-file.c), It says

CDATA element do not use character entities, but also need the "]]" terminator added at the end.

But I still don't understand the reason for the "]]" terminator.
I have do a test:
1、new a CDATA node by 'mxmlNewCDATA', the data is "test for cdata"
2、read the node by 'mxmlGetCDATA' immediately
3、save the whole tree to a xml file

The result is:
->2、the string read out is more than a ']]', it is "test for cdata]]"
->3、in the xml file, the CDATA has a redundant "]]", it is

<![CDATA[test for cdata]]]]>

But as I known, it should be

<![CDATA[test for cdata]]>

Is this a bug or for other purpose ? @michaelrsweet

@slzhu slzhu changed the title Write CDATA node with a redundant "]]". Write CDATA node with a redundant "]]" Mar 2, 2018
@michaelrsweet
Copy link
Owner

mxmlNewCDATA adds the "<![CDATA[...]]" wrapper around the string for you. When you call mxmlGetCDATA the returned string includes the trailing "]]" (since it was added for you).

I will add a note about this to the documentation, but short of making a copy of the string there isn't any way around this in Mini-XML 2.x. In 3.x I plan on making CDATA nodes have their own type so we can just store the raw string.

@michaelrsweet michaelrsweet self-assigned this Jul 2, 2018
@michaelrsweet michaelrsweet added question General usage question bug Something isn't working and removed question General usage question labels Jul 2, 2018
@michaelrsweet
Copy link
Owner

Actually, looking at the load code we strip the trailing "]]", so mxmlNewCDATA should do the same.

@michaelrsweet michaelrsweet reopened this Jul 2, 2018
@michaelrsweet michaelrsweet added this to the Stable milestone Jul 2, 2018
@michaelrsweet
Copy link
Owner

Fixed:

[master e0db328] Don't add ]] to the CDATA node (Issue #216)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants