[PATCH] sub_filter bug

anthrax at unixuser.org anthrax at unixuser.org
Thu May 22 07:53:40 UTC 2014


Hi,

Could you take a look at the following patch?


# HG changeset patch
# User KAWAHARA Masashi <anthrax at unixuser.org>
# Date 1400671481 -32400
#      Wed May 21 20:24:41 2014 +0900
# Node ID 3949e591694fff37a436a076f4d4006c802587c7
# Parent  1209b8a7b077c7bbf161e502964308736c84db6f
Bugfix: When both sub_filter and SSI were used and the include file was
       not terminated by newline, it was transmitted incorrectly.
ex.
conf:
  ssi on
  sub_filter '//check-string' '//replace-string'

contents:
  index.shtml:
    <!--#include virtual="/test.html"-->//check-string

  test.html:  (!! saved no newline at end of line !!)
    include-text/

output:
  include-test//replace-string

correct output:
  include-test///replace-string

diff -r 1209b8a7b077 -r 3949e591694f src/http/modules/ngx_http_sub_filter_module.c
--- a/src/http/modules/ngx_http_sub_filter_module.c     Tue May 20 16:10:07 2014 +0400
+++ b/src/http/modules/ngx_http_sub_filter_module.c     Wed May 21 20:24:41 2014 +0900
@@ -539,6 +539,9 @@
 
             for ( ;; ) {
                 if (ch == match) {
+                    if ((p + 1) == last && state != sub_match_state) {
+                        goto match_started;
+                    }
                     copy_end = p;
                     ctx->looked.data[0] = *p;
                     looked = 1;



More information about the nginx-devel mailing list