-
Notifications
You must be signed in to change notification settings - Fork 606
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
Add forceCdata option to builder to force the use of CDATA tags for all content. #396
base: master
Are you sure you want to change the base?
Conversation
Why would I want to wrap things in unnecessary |
We've run into a situation where a parser (that we don't control) requires CDATA on all text content, like what's described in #321. I'm not sure how common this is, but the ability to always force CDATA has served us well. |
Truth be told, I am not very fond of outputting nonsensical XML just because something that claims it parses XML does not do it properly. It is like saying "we have a parser that doesn't handle characters, so we should encode every character via XML entities". |
@Leonidas-from-XIV We met the same problem, some company require CDATA on all text content, but we can't say they're wrong and fix for us. So we have to change our code in workspace use CDATA force. We hope there'll be coming a long-term solution. |
same problem here |
Same for us. One of the german services requires all the data to be wrapped into CDATA |
In my case, I have a bunch of attributes containing special characters like "&", it gets converted to to "$amp;"...is there any way I can avoid this add make all my attributes retain values using CDATA? |
Same problem here |
+1 |
Same problem with Wechat. Now I have to use a template string instead of |
Anything? |
Just wanted to elaborate on this suggestion. It could be implemented as the following:
|
This PR adds a
forceCdata
option to the XML builder that wraps all text nodes in CDATA even when it is not required. This option is set tofalse
by default. A new test exercises theforceCdata
option using a small sample of text that does not require escaping.