Welcome! Log In Create A New Profile

Advanced

Re: [PATCH 2 of 4] Set done flag on module context to stop further chunk parsing

Maxim Dounin
March 27, 2012 10:04PM
Hello!

On Wed, Mar 21, 2012 at 09:28:32PM +0000, Laurence Rowe wrote:

> # HG changeset patch
> # User Laurence Rowe <laurence@lrowe.co.uk>
> # Date 1332363776 0
> # Node ID 151124d060d3f725c02b656d39c10575ff009cdb
> # Parent 28a1437a8b4492530a24d51b85aca7923627c330
> Set done flag on module context to stop further chunk parsing.
>
> As HTML parsing will recover from non-fatal errors, the return value of
> (x|ht)mlParseChunk cannot be used.
>
> diff --git a/src/http/modules/ngx_http_xslt_filter_module.c b/src/http/modules/ngx_http_xslt_filter_module.c
> --- a/src/http/modules/ngx_http_xslt_filter_module.c
> +++ b/src/http/modules/ngx_http_xslt_filter_module.c
> @@ -378,7 +378,7 @@
> err = xmlParseChunk(ctx->ctxt, (char *) b->pos, (int) (b->last - b->pos),
> (b->last_buf) || (b->last_in_chain));
>
> - if (err == 0) {
> + if (ctx->done == 0) {
> b->pos = b->last;
> return NGX_OK;
> }
> @@ -463,6 +463,8 @@
>
> ngx_log_error(NGX_LOG_ERR, ctx->request->connection->log, 0,
> "libxml2 error: \"%*s\"", n + 1, buf);
> +
> + ctx->done = 1; /* stop further chunk parsing */
> }

I believe this doesn't cover all possible fatal errors as returned
by xmlParseChunk(). At least this one isn't covered:

....
if (ctxt == NULL)
return(XML_ERR_INTERNAL_ERROR);
....

While it probably not very common, I still think we need a better
way to differentiate recoverable errors in html parsing.

Maxim Dounin

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 0 of 4] XSLT HTML parsing

Laurence Rowe 1289 March 21, 2012 05:30PM

[PATCH 3 of 4] xslt_html_parser directive

Laurence Rowe 571 March 21, 2012 05:30PM

[PATCH 2 of 4] Set done flag on module context to stop further chunk parsing

Laurence Rowe 502 March 21, 2012 05:40PM

Re: [PATCH 2 of 4] Set done flag on module context to stop further chunk parsing

Maxim Dounin 578 March 27, 2012 10:04PM

[PATCH 4 of 4] Handle empty response body

Laurence Rowe 489 March 21, 2012 05:40PM

Re: [PATCH 4 of 4] Handle empty response body

Maxim Dounin 513 March 27, 2012 10:04PM

[PATCH 1 of 4] Set parser options with xmlCtxtUseOptions

Laurence Rowe 552 March 21, 2012 05:40PM

Re: [PATCH 1 of 4] Set parser options with xmlCtxtUseOptions

Maxim Dounin 551 March 27, 2012 09:58PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 204
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready