1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Fix handling of incomplete processing instructions

When doing incremental rendering we now require the whole thing to be there
and that there is room for two tokens in the scanner token table.  This is
necessary because we have to generate both a processing target token and a
processing data token to make life simpler for the parser.

Remove processing instruction data case label from the main parser loop. It
is safer this way since it already assumes that the processing target token
has been stored.
This commit is contained in:
Jonas Fonseca 2006-01-28 03:35:36 +01:00 committed by Jonas Fonseca
parent 823c594524
commit 95c1de2315
2 changed files with 24 additions and 2 deletions

View File

@ -364,7 +364,6 @@ parse_sgml_plain(struct dom_stack *stack, struct dom_scanner *scanner)
assert(token->type == SGML_TOKEN_PROCESS_DATA); assert(token->type == SGML_TOKEN_PROCESS_DATA);
/* Fall-through */ /* Fall-through */
case SGML_TOKEN_PROCESS_DATA:
if (!add_sgml_proc_instruction(stack, &target, token)) if (!add_sgml_proc_instruction(stack, &target, token))
return SGML_PARSER_CODE_MEM_ALLOC; return SGML_PARSER_CODE_MEM_ALLOC;
if ((target.type == SGML_TOKEN_PROCESS_XML if ((target.type == SGML_TOKEN_PROCESS_XML

View File

@ -543,6 +543,29 @@ scan_sgml_element_token(struct dom_scanner *scanner, struct dom_scanner_token *t
possibly_incomplete = 0; possibly_incomplete = 0;
} }
if (scanner->check_complete && scanner->incomplete) {
/* We need to fit both the process target token
* and the process data token into the scanner
* table. */
if (token + 1 >= scanner->table + DOM_SCANNER_TOKENS) {
possibly_incomplete = 1;
} else if (!possibly_incomplete) {
/* FIXME: We do this twice. */
for (pos = string + 1;
(pos = skip_sgml_chars(scanner, pos, '>'));
pos++) {
if (pos[-1] == '?')
break;
}
if (!pos)
possibly_incomplete = 1;
}
if (possibly_incomplete)
string = scanner->end;
}
} else if (*string == '/') { } else if (*string == '/') {
string++; string++;
skip_sgml_space(scanner, &string); skip_sgml_space(scanner, &string);
@ -707,7 +730,7 @@ scan_sgml_proc_inst_token(struct dom_scanner *scanner, struct dom_scanner_token
/* The length can be empty for '<??>'. */ /* The length can be empty for '<??>'. */
ssize_t length = -1; ssize_t length = -1;
token->string.string = string; token->string.string = string++;
/* Figure out where the processing instruction ends. This doesn't use /* Figure out where the processing instruction ends. This doesn't use
* skip_sgml() since we MUST ignore precedence here to allow '<' inside * skip_sgml() since we MUST ignore precedence here to allow '<' inside