Poorly hack in cdata parsing
Some checks are pending
Clixon CI / ubuntu-build (push) Waiting to run
Clixon CI / ubuntu-build-restconf-fcgi (push) Waiting to run
Clixon CI / docker-alpine-test-1 (push) Waiting to run
Clixon CI / docker-alpine-test-2 (push) Waiting to run
Clixon CI / docker-alpine-test-3 (push) Waiting to run
Clixon CI / docker-alpine-test-fcgi-r (push) Waiting to run

This commit is contained in:
Tassilo Schweyer 2025-03-23 23:24:46 +01:00
parent e6eccd4431
commit 5513959eb4

View file

@ -530,6 +530,7 @@ xml_chardata_encode(char **escp,
len += strlen("&");
break;
case '<':
// <![CDATA[
if (strncmp(&str[i], "<![CDATA[", strlen("<![CDATA[")) == 0){
len++;
cdata++;
@ -801,6 +802,7 @@ xml_chardata_decode(char **decp,
int j;
char ch;
int ret;
int cdata;
/* Two steps: (1) read in the complete format string */
va_start(args, fmt); /* dryrun */
@ -824,8 +826,17 @@ xml_chardata_decode(char **decp,
goto done;
}
j = 0;
cdata = 0;
memset(dec, 0, slen+1);
for (i=0; i<slen; i++){
if (cdata) {
if ((i+2) < slen) && (strncmp(&str[i], "]]>", strlen("]]>")) == 0)){
cdata = 0;
i += 2;
} else {
dec[j++] = str[i];
}
} else {
ch = str[i];
switch (ch){
case '&':
@ -836,6 +847,13 @@ xml_chardata_decode(char **decp,
else
dec[j++] = ch;
break;
case '<':
if (strncmp(&str[i], "<![CDATA[", strlen("<![CDATA[")) == 0){
cdata++;
i += 8;
break;
}
default:
dec[j++] = str[i];
}