mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
A handful of fixes related to error detection
- Fix assertion failure by breaking the switch if an error token is next when previous was a processing instruction. - Fix <!notation parsing by skipping ident chars instead of spaces. - Improve checking of processing instruction 'target'-end and what error string is generated. - For now put all of the processing instruction data in the error token. - Remove a DBG()-print.
This commit is contained in:
parent
97f403a9d9
commit
3835bf8449
@ -336,8 +336,13 @@ parse_sgml_plain(struct dom_stack *stack, struct dom_scanner *scanner)
|
|||||||
if (!token || token->type == SGML_TOKEN_INCOMPLETE)
|
if (!token || token->type == SGML_TOKEN_INCOMPLETE)
|
||||||
return SGML_PARSER_CODE_INCOMPLETE;
|
return SGML_PARSER_CODE_INCOMPLETE;
|
||||||
|
|
||||||
assert(token->type == SGML_TOKEN_PROCESS_DATA);
|
if (token->type == SGML_TOKEN_ERROR)
|
||||||
|
break;
|
||||||
|
|
||||||
|
assert(token->type == SGML_TOKEN_PROCESS_DATA);
|
||||||
|
/* Fall-through */
|
||||||
|
|
||||||
|
case SGML_TOKEN_PROCESS_DATA:
|
||||||
if (add_sgml_proc_instruction(stack, &target, token)
|
if (add_sgml_proc_instruction(stack, &target, token)
|
||||||
&& (target.type == SGML_TOKEN_PROCESS_XML
|
&& (target.type == SGML_TOKEN_PROCESS_XML
|
||||||
|| target.type == SGML_TOKEN_PROCESS_XML_STYLESHEET)
|
|| target.type == SGML_TOKEN_PROCESS_XML_STYLESHEET)
|
||||||
|
@ -449,7 +449,7 @@ scan_sgml_element_token(struct dom_scanner *scanner, struct dom_scanner_token *t
|
|||||||
assert(real_length >= 0);
|
assert(real_length >= 0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
skip_sgml_space(scanner, &string);
|
scan_sgml(scanner, string, SGML_CHAR_IDENT);
|
||||||
type = map_dom_scanner_string(scanner, ident, string, base);
|
type = map_dom_scanner_string(scanner, ident, string, base);
|
||||||
if (skip_sgml(scanner, &string, '>', 0)) {
|
if (skip_sgml(scanner, &string, '>', 0)) {
|
||||||
/* We found the end. */
|
/* We found the end. */
|
||||||
@ -473,7 +473,9 @@ scan_sgml_element_token(struct dom_scanner *scanner, struct dom_scanner_token *t
|
|||||||
real_length = string - token->string.string;
|
real_length = string - token->string.string;
|
||||||
skip_sgml_space(scanner, &string);
|
skip_sgml_space(scanner, &string);
|
||||||
|
|
||||||
if (is_sgml_space(string[-1])) {
|
/* Make '<?xml ' cause the right kind of error. */
|
||||||
|
if (is_sgml_space(string[-1])
|
||||||
|
&& string < scanner->end) {
|
||||||
/* We found the end. */
|
/* We found the end. */
|
||||||
possibly_incomplete = 0;
|
possibly_incomplete = 0;
|
||||||
}
|
}
|
||||||
@ -610,7 +612,6 @@ scan_sgml_element_token(struct dom_scanner *scanner, struct dom_scanner_token *t
|
|||||||
if (check_sgml_error(scanner)) {
|
if (check_sgml_error(scanner)) {
|
||||||
unsigned char *end = string;
|
unsigned char *end = string;
|
||||||
|
|
||||||
DBG("%d %d", type, SGML_TOKEN_NOTATION_DOCTYPE);
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SGML_TOKEN_CDATA_SECTION:
|
case SGML_TOKEN_CDATA_SECTION:
|
||||||
case SGML_TOKEN_NOTATION_ATTLIST:
|
case SGML_TOKEN_NOTATION_ATTLIST:
|
||||||
@ -631,6 +632,16 @@ scan_sgml_element_token(struct dom_scanner *scanner, struct dom_scanner_token *t
|
|||||||
end = scanner->position + 6;
|
end = scanner->position + 6;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SGML_TOKEN_PROCESS_XML:
|
||||||
|
if (scanner->position + 5 < end)
|
||||||
|
end = scanner->position + 5;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SGML_TOKEN_PROCESS_XML_STYLESHEET:
|
||||||
|
if (scanner->position + 16 < end)
|
||||||
|
end = scanner->position + 16;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -681,7 +692,7 @@ scan_sgml_proc_inst_token(struct dom_scanner *scanner, struct dom_scanner_token
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (check_sgml_error(scanner)) {
|
if (check_sgml_error(scanner)) {
|
||||||
token = set_sgml_error(scanner, scanner->position + 2);
|
token = set_sgml_error(scanner, string);
|
||||||
if (!token)
|
if (!token)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user