mirror of
https://gitea.psi.ch/ELOG/mxml.git
synced 2026-09-09 01:23:22 +00:00
ENTITY is always inside DOCTYPE.
This commit is contained in:
parent
3e3b113ec0
commit
7a51782672
42
mxml.c
42
mxml.c
@ -1098,7 +1098,7 @@ PMXML_NODE mxml_parse_buffer(char *buf, char *error, int error_size)
|
|||||||
{
|
{
|
||||||
char node_name[256], attrib_name[256], attrib_value[1000];
|
char node_name[256], attrib_name[256], attrib_value[1000];
|
||||||
char *p, *pv;
|
char *p, *pv;
|
||||||
int i, line_number;
|
int i,j, line_number;
|
||||||
PMXML_NODE root, ptree, pnew;
|
PMXML_NODE root, ptree, pnew;
|
||||||
int end_element;
|
int end_element;
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -1177,28 +1177,24 @@ PMXML_NODE mxml_parse_buffer(char *buf, char *error, int error_size)
|
|||||||
|
|
||||||
p += 2;
|
p += 2;
|
||||||
|
|
||||||
} else if (strncmp(p, "!ENTITY", 7) == 0) {
|
} else if (strncmp(p, "!DOCTYPE", 8) == 0 ) {
|
||||||
|
|
||||||
/* found !ENTITY element */
|
/* found !DOCTYPE element , skip it */
|
||||||
pnew = mxml_add_special_node(ptree, ENTITY_NODE, "ENTYTY", NULL);
|
p += 8;
|
||||||
pv = p + 1;
|
|
||||||
|
|
||||||
p++;
|
|
||||||
if (strstr(p, ">") == NULL)
|
if (strstr(p, ">") == NULL)
|
||||||
return read_error(HERE, "Unterminated !ENTITY element");
|
return read_error(HERE, "Unterminated !DOCTYPE element");
|
||||||
|
|
||||||
while (*p != '>') {
|
j = 0;
|
||||||
|
while (*p != '>' || j > 0) {
|
||||||
if (*p == '\n')
|
if (*p == '\n')
|
||||||
line_number++;
|
line_number++;
|
||||||
|
else if (*p == '<')
|
||||||
|
j++;
|
||||||
|
else if (*p == '>')
|
||||||
|
j--;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = (size_t)p - (size_t)pv;
|
|
||||||
pnew->value = (char *)malloc(len+1);
|
|
||||||
memcpy(pnew->value, pv, len);
|
|
||||||
pnew->value[len] = 0;
|
|
||||||
mxml_decode(pnew->value);
|
|
||||||
|
|
||||||
p ++;
|
p ++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -1432,13 +1428,23 @@ PMXML_NODE mxml_parse_entity(char **buf, char *error, int error_size)
|
|||||||
return read_error(HERE, "Cannot allocate memory.");
|
return read_error(HERE, "Cannot allocate memory.");
|
||||||
}
|
}
|
||||||
strcpy(buffer, *buf);
|
strcpy(buffer, *buf);
|
||||||
|
|
||||||
|
p = strstr(buffer,"!DOCTYPE");
|
||||||
|
if(p == NULL) /* no entities */
|
||||||
|
return root;
|
||||||
|
|
||||||
|
pv = strstr(p,"[");
|
||||||
|
if(pv == NULL) /* no entities */
|
||||||
|
return root;
|
||||||
|
|
||||||
free(*buf);
|
free(*buf);
|
||||||
|
p = pv + 1;
|
||||||
p = buffer;
|
|
||||||
|
|
||||||
|
|
||||||
/* search !ENTITY */
|
/* search !ENTITY */
|
||||||
do {
|
do {
|
||||||
|
if (*p == ']')
|
||||||
|
break;
|
||||||
|
|
||||||
if (*p == '<') {
|
if (*p == '<') {
|
||||||
|
|
||||||
/* found new entity */
|
/* found new entity */
|
||||||
|
|||||||
1
mxml.h
1
mxml.h
@ -18,7 +18,6 @@
|
|||||||
#define PROCESSING_INSTRUCTION_NODE 3
|
#define PROCESSING_INSTRUCTION_NODE 3
|
||||||
#define COMMENT_NODE 4
|
#define COMMENT_NODE 4
|
||||||
#define DOCUMENT_NODE 5
|
#define DOCUMENT_NODE 5
|
||||||
#define ENTITY_NODE 6
|
|
||||||
|
|
||||||
#define INTERNAL_ENTITY 0
|
#define INTERNAL_ENTITY 0
|
||||||
#define EXTERNAL_ENTITY 1
|
#define EXTERNAL_ENTITY 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user