Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

CDATA blocks with ] or [ characters inside#2

Merged
c4milo merged 1 commit into
buglabs:masterfrom
andris9:master
Aug 10, 2011
Merged

CDATA blocks with ] or [ characters inside#2
c4milo merged 1 commit into
buglabs:masterfrom
andris9:master

Conversation

@andris9

@andris9 andris9 commented Aug 4, 2011

Copy link
Copy Markdown

If a CDATA block includes ] or [ characters then the textual data for the element is passed several times in separate blocks. Currently only the last of these blocks is used.

For example

<![CDATA[ test1 test2 ] test3 ]]>

Will be added as the text node as

$t: "] test3 "

When actually it should be

$t: " test1 test2 ] test3 "

@frederickcook

Copy link
Copy Markdown

Bump. Critical fix, and needs to be in the npm version to deploy to Heroku without getting hacky.

Thanks to @andris9 for finding and patching.

c4milo added a commit that referenced this pull request Aug 10, 2011
CDATA blocks with ] or [ characters inside

Notes in our README regarding no parsing support for CDATA sections will remain. Please notice that we also provide a way to generate reversible json and this patch doesn't resolve that case.  The right way to parse CDATA sections will be something like: 

1. xml2json: Handling startCdata and endCdata events coming from node-expat
2. xml2json: In order to continue supporting reversible json, generate a new identifier to represent the cdata section in json.
3. json2xml: generate the CDATA sections in xml appropriately 
4. write tests
@c4milo c4milo merged commit 7ffef62 into buglabs:master Aug 10, 2011
@c4milo

c4milo commented Aug 10, 2011

Copy link
Copy Markdown
Contributor

Thanks Andris for the pull request.

I merged your patch but please be aware that notes in our README regarding no parsing support for CDATA sections will remain. Please notice that we also provide a way to generate reversible json and this patch doesn't resolve that case. The right way to parse CDATA sections will be something like:

  1. xml2json: Handling startCdata and endCdata events coming from node-expat
  2. xml2json: In order to continue supporting reversible json, generate a new identifier to represent the cdata section in json.
  3. json2xml: generate the CDATA sections in xml appropriately
  4. write tests

@andris9

andris9 commented Aug 10, 2011

Copy link
Copy Markdown
Author

Thanks for clarifying and pulling! In my case I was not interested keeping the exact structure of the XML source but just get the text value out from a block sometimes defined as CDATA in my RSS module

c4milo pushed a commit that referenced this pull request Nov 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants