1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-01 03:36:26 -04: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:
Jonas Fonseca 2006-01-07 05:18:43 +01:00 committed by Jonas Fonseca
parent 97f403a9d9
commit 3835bf8449
2 changed files with 21 additions and 5 deletions

View File

@ -336,8 +336,13 @@ parse_sgml_plain(struct dom_stack *stack, struct dom_scanner *scanner)
if (!token || token->type == SGML_TOKEN_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)
&& (target.type == SGML_TOKEN_PROCESS_XML
|| target.type == SGML_TOKEN_PROCESS_XML_STYLESHEET)

View File

@ -449,7 +449,7 @@ scan_sgml_element_token(struct dom_scanner *scanner, struct dom_scanner_token *t
assert(real_length >= 0);
} else {
skip_sgml_space(scanner, &string);
scan_sgml(scanner, string, SGML_CHAR_IDENT);
type = map_dom_scanner_string(scanner, ident, string, base);
if (skip_sgml(scanner, &string, '>', 0)) {
/* 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;
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. */
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)) {
unsigned char *end = string;
DBG("%d %d", type, SGML_TOKEN_NOTATION_DOCTYPE);
switch (type) {
case SGML_TOKEN_CDATA_SECTION:
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;
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:
break;
}
@ -681,7 +692,7 @@ scan_sgml_proc_inst_token(struct dom_scanner *scanner, struct dom_scanner_token
}
if (check_sgml_error(scanner)) {
token = set_sgml_error(scanner, scanner->position + 2);
token = set_sgml_error(scanner, string);
if (!token)
return;
}