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

Laurence Rowe l at lrowe.co.uk
Wed Mar 21 21:28:32 UTC 2012


# HG changeset patch
# User Laurence Rowe <laurence at 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 */
 }
 
 



More information about the nginx-devel mailing list