Skip to content

Conversation

@rv-kip
Copy link

@rv-kip rv-kip commented Dec 13, 2014

  • Allowing selective disabling of CDATA wrapping by field name.
  • Adding items by concatenation of exiting items of by replacement
  • Associated unit tests
  • example code
  • Readme updates.

This is similar to existing PR #28, but allows for finer control over what fields can be skipped for CDATA wrapping.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example of specifying a field for no CDATA wrapping

@jasonkarns
Copy link
Collaborator

Might I suggest the option be named something other than no_cdata_fields? Perhaps, no_encode_fields or similar? Including 'cdata' in the name implies something special with cdata, when in fact the option is just disabling the encoding of the listed elements. node-rss could just as well search/replace all <, &, etc and not use cdata at all. In which case, this option would disable search/replace encoding instead. (since there isn't any difference between cdata and entity-encoding as far as xml is concerned) And as cdata is a particular mechanism of encoding, I suggest the more generic term be used for the option instead.

@rv-kip
Copy link
Author

rv-kip commented Dec 16, 2014

Seems like a good suggestion. The xml module in node-rss already handles escaping of the fields if they are not specified with the CDATA attribute.

So, depending on the no_encode_fields flag,
title: 'item & <div>title</div>'
becomes
<title><![CDATA[item & <div>title</div>]]></title>
or
<title>item &amp; &lt;div&gt;title&lt;/div&gt;</title>

@jasonkarns
Copy link
Collaborator

The xml module in node-rss already handles escaping of the fields if they are not specified with the CDATA attribute.

@rv-kip I must have misunderstood, then. If the elements are going to be encoded regardless whether they're in a CDATA block or not, then the no_encode_fields name doesn't fit. But now I'm really confused at the point of this PR. Consumers shouldn't care at all whether a particular field is entity-encoded or wrapped in CDATA. XML parsers treat either case identically. As a proper xml producer, both forms are indistinguishable.

@rv-kip
Copy link
Author

rv-kip commented Dec 16, 2014

In my use-case, some consumers of the generated XML/RSS will display the "CDATA" tags as if they were part of the content. This is a due to the heterogeneity of our XML clients. Being able to suppress the CDATA tags and escape the data for particular fields turns them into text fields that will display properly.

@jasonkarns
Copy link
Collaborator

As long as it's clear that this change (or a portion thereof) is to support
non-compliant XML clients.

Personally, I wouldn't accept any code meant solely to satisfy non
conformant parsers, but I don't own this project. :)

An alternative would be to wrap node-rss in a custom adapter object. This
way the scar tissue of dealing with non-conformant parsers would be cleanly
separated from node-rss. In fact, it would make a decent node module in its
own right (accepting arbitrary xml doms and serializing exclusively with
entity-encoding).

my 2 cents

On Tue, Dec 16, 2014 at 2:24 PM, Kip Gebhardt [email protected]
wrote:

In my use-case, some consumers of the generated XML/RSS will display the
"CDATA" tags as if they were part of the content. This is a due to the
heterogeneity of our XML clients. Being able to suppress the CDATA tags and
escape the data for particular fields turns them into text fields that will
display properly.


Reply to this email directly or view it on GitHub
#37 (comment).

@rv-kip
Copy link
Author

rv-kip commented Dec 16, 2014

Yep. It clearly isn't ideal that some clients behave incorrectly, but the XML landscape isn't a perfect one. Perhaps no_cdata_fields is a clearer name.

@jasonkarns
Copy link
Collaborator

Yeah, if the result will be encoded either way, better that the option be
named to convey precisely what it's doing.

On Tue, Dec 16, 2014 at 2:38 PM, Kip Gebhardt [email protected]
wrote:

Yep. It clearly isn't ideal that some clients behave incorrectly, but the
XML landscape isn't a perfect one. Perhaps no_cdata_fields is a clearer
name.


Reply to this email directly or view it on GitHub
#37 (comment).

Kip Gebhardt added 4 commits December 16, 2014 14:18
…. Adding test for XML escaping when no_cdata_fields is used
… by item() resulting in inconsistencies like missing category field. Added test for this issue
@rv-kip
Copy link
Author

rv-kip commented Dec 18, 2014

I found a couple of typos and a bug while developing against this PR. I'll stop adding to it now ;)

@dylang
Copy link
Owner

dylang commented Dec 19, 2014

Hi @rv-kip. I feel like a jerk because I touched a lot of the code while your PR was in flight and this might be a painful merge.

Do you want to try pull in the latest from master? Or split it into smaller PR's?

readme.md Outdated
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The readme file is generated.

grunt pre-publish to re-generate it.

The files it uses are in /templates/readme.

@rv-kip
Copy link
Author

rv-kip commented Dec 19, 2014

No problem. I'll resubmit a PR from latest master. This can be closed.

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

Successfully merging this pull request may close these issues.

4 participants