mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Parse <[CDATA[ sections ]]>
This commit is contained in:
parent
b9c5bc5536
commit
98d7263c2f
@ -282,6 +282,11 @@ parse_sgml_document(struct dom_stack *stack, struct scanner *scanner)
|
|||||||
skip_scanner_token(scanner);
|
skip_scanner_token(scanner);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SGML_TOKEN_CDATA_SECTION:
|
||||||
|
add_sgml_node(stack, DOM_NODE_CDATA_SECTION, token);
|
||||||
|
skip_scanner_token(scanner);
|
||||||
|
break;
|
||||||
|
|
||||||
case SGML_TOKEN_PROCESS_XML:
|
case SGML_TOKEN_PROCESS_XML:
|
||||||
if (!add_sgml_proc_instruction(stack, token)) {
|
if (!add_sgml_proc_instruction(stack, token)) {
|
||||||
skip_sgml_tokens(scanner, SGML_TOKEN_TAG_END);
|
skip_sgml_tokens(scanner, SGML_TOKEN_TAG_END);
|
||||||
|
@ -194,6 +194,23 @@ skip_comment(struct scanner *scanner, unsigned char **string)
|
|||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
skip_cdata_section(struct scanner *scanner, unsigned char **string)
|
||||||
|
{
|
||||||
|
unsigned char *pos = *string;
|
||||||
|
int length = 0;
|
||||||
|
|
||||||
|
for (; pos < scanner->end - 3; pos++)
|
||||||
|
if (pos[0] == ']' && pos[1] == ']' && pos[2] == '>') {
|
||||||
|
length = pos - *string;
|
||||||
|
pos += 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
*string = pos;
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
#define scan_sgml_attribute(scanner, str) \
|
#define scan_sgml_attribute(scanner, str) \
|
||||||
while ((str) < (scanner)->end && is_sgml_attribute(*(str))) \
|
while ((str) < (scanner)->end && is_sgml_attribute(*(str))) \
|
||||||
(str)++;
|
(str)++;
|
||||||
@ -249,6 +266,16 @@ scan_sgml_element_token(struct scanner *scanner, struct scanner_token *token)
|
|||||||
token->string = string;
|
token->string = string;
|
||||||
real_length = skip_comment(scanner, &string);
|
real_length = skip_comment(scanner, &string);
|
||||||
assert(real_length >= 0);
|
assert(real_length >= 0);
|
||||||
|
|
||||||
|
} else if (string + 6 < scanner->end
|
||||||
|
&& !memcmp(string, "[CDATA[", 7)) {
|
||||||
|
|
||||||
|
string += 7;
|
||||||
|
type = SGML_TOKEN_CDATA_SECTION;
|
||||||
|
token->string = string;
|
||||||
|
real_length = skip_cdata_section(scanner, &string);
|
||||||
|
assert(real_length >= 0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
scan_sgml(scanner, string, SGML_CHAR_IDENT);
|
scan_sgml(scanner, string, SGML_CHAR_IDENT);
|
||||||
type = map_scanner_string(scanner, ident, string, base);
|
type = map_scanner_string(scanner, ident, string, base);
|
||||||
|
@ -25,6 +25,8 @@ enum sgml_token_type {
|
|||||||
SGML_TOKEN_NOTATION_ENTITY, /* <!ENTITY until > */
|
SGML_TOKEN_NOTATION_ENTITY, /* <!ENTITY until > */
|
||||||
SGML_TOKEN_NOTATION_ATTLIST, /* <!ATTLIST until > */
|
SGML_TOKEN_NOTATION_ATTLIST, /* <!ATTLIST until > */
|
||||||
|
|
||||||
|
SGML_TOKEN_CDATA_SECTION, /* <![CDATA[ until ]]> */
|
||||||
|
|
||||||
SGML_TOKEN_PROCESS, /* <?{ident} until ?> */
|
SGML_TOKEN_PROCESS, /* <?{ident} until ?> */
|
||||||
SGML_TOKEN_PROCESS_XML, /* <?xml until */
|
SGML_TOKEN_PROCESS_XML, /* <?xml until */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user