* XML to JSON CDATA translation is NOT stripped
* Example, assume XML: `<s><![CDATA[ z > x & x < y ]]></s>`
* Previous bevavior:
* JSON: {"s":" z > x & x < y "}
* New behavior:
* JSON: `{"s":"<![CDATA[ z > x & x < y ]]>"}`
* To keep old behavior, set `JSON_CDATA_STRIP` in clixon_custom.h
This commit is contained in:
parent
7976c11f11
commit
81da71ffd7
5 changed files with 61 additions and 16 deletions
|
|
@ -256,9 +256,11 @@ json_str_escape_cdata(cbuf *cb,
|
|||
{
|
||||
int retval = -1;
|
||||
int i;
|
||||
int esc = 0; /* cdata escape */
|
||||
size_t len;
|
||||
|
||||
#ifdef JSON_CDATA_STRIP
|
||||
int esc = 0; /* cdata escape */
|
||||
#endif
|
||||
|
||||
len = strlen(str);
|
||||
for (i=0; i<len; i++)
|
||||
switch (str[i]){
|
||||
|
|
@ -271,6 +273,7 @@ json_str_escape_cdata(cbuf *cb,
|
|||
case '\\':
|
||||
cprintf(cb, "\\\\");
|
||||
break;
|
||||
#ifdef JSON_CDATA_STRIP
|
||||
case '<':
|
||||
if (!esc &&
|
||||
strncmp(&str[i], "<![CDATA[", strlen("<![CDATA[")) == 0){
|
||||
|
|
@ -289,6 +292,7 @@ json_str_escape_cdata(cbuf *cb,
|
|||
else
|
||||
cprintf(cb, "%c", str[i]);
|
||||
break;
|
||||
#endif /* JSON_CDATA_STRIP */
|
||||
default: /* fall thru */
|
||||
cprintf(cb, "%c", str[i]);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue