diff --git a/t/conf/proxy.conf.in b/t/conf/proxy.conf.in index 5924d89c..4ec1c37b 100644 --- a/t/conf/proxy.conf.in +++ b/t/conf/proxy.conf.in @@ -360,6 +360,43 @@ Alias /modules/proxy/fcgi-uds-sethandler @SERVERROOT@/htdocs/modules/proxy/fcgi ProxyPass http://@SERVERNAME@:@PORT@/modules/proxy_html + # Comment-after-rewrite test (regression for garbage after + # comments following rewritten URLs) + + ProxyHTMLFixups reset + ProxyHTMLEnable on + ProxyHTMLExtended off + ProxyHTMLStripComments off + ProxyHTMLLinks a href + ProxyHTMLLinks link href + ProxyHTMLURLMap http://a.example.com/ http://b.example.com/ + ProxyPass http://@SERVERNAME@:@PORT@/modules/proxy_html + + + # Comment stripping with extfix off + + ProxyHTMLFixups reset + ProxyHTMLEnable on + ProxyHTMLExtended off + ProxyHTMLStripComments on + ProxyHTMLLinks a href + ProxyHTMLLinks link href + ProxyHTMLURLMap http://a.example.com/ http://b.example.com/ + ProxyPass http://@SERVERNAME@:@PORT@/modules/proxy_html + + + # Comment-after-rewrite with extfix on + + ProxyHTMLFixups reset + ProxyHTMLEnable on + ProxyHTMLExtended on + ProxyHTMLStripComments off + ProxyHTMLLinks a href + ProxyHTMLLinks link href + ProxyHTMLURLMap http://a.example.com/ http://b.example.com/ + ProxyPass http://@SERVERNAME@:@PORT@/modules/proxy_html + + # Multiple URL maps test ProxyHTMLEnable on diff --git a/t/htdocs/modules/proxy_html/comment_rewrite.html b/t/htdocs/modules/proxy_html/comment_rewrite.html new file mode 100644 index 00000000..bf5ea5cc --- /dev/null +++ b/t/htdocs/modules/proxy_html/comment_rewrite.html @@ -0,0 +1,14 @@ + + + + Comment After Rewrite Test + + + + + + Link 1 + + Link 2 + + diff --git a/t/modules/proxy_html.t b/t/modules/proxy_html.t index 4212ebc8..bbcedc28 100644 --- a/t/modules/proxy_html.t +++ b/t/modules/proxy_html.t @@ -156,6 +156,55 @@ my @tests = ( { type => 'url_rewrite', path => 'multi_subst_rx/multi_subst_rx.html', pattern => 'RX_EVENT_END_OK', desc => 'event attr preserved after regex multi-substitution' }, + # Comment-after-rewrite regression tests (garbage introduced after + # comments that follow rewritten URLs, fixed in 2.4.69) + { type => 'url_rewrite', path => 'comment_rewrite/comment_rewrite.html', + pattern => 'http://b\\.example\\.com/static/images/favicon\\.png', desc => 'rewritten URL before comment', + minver => '2.4.69' }, + { type => 'url_rewrite', path => 'comment_rewrite/comment_rewrite.html', + pattern => '', desc => 'comment preserved after rewrite', + minver => '2.4.69' }, + { type => 'url_rewrite', path => 'comment_rewrite/comment_rewrite.html', + pattern => 'http://b\\.example\\.com/static/plugins/fontawesome-free/css/all\\.min\\.css', + desc => 'rewritten URL after comment not corrupted', + minver => '2.4.69' }, + { type => 'url_rewrite', path => 'comment_rewrite/comment_rewrite.html', + pattern => '', desc => 'inline comment preserved after rewrite', + minver => '2.4.69' }, + { type => 'url_rewrite', path => 'comment_rewrite/comment_rewrite.html', + pattern => '-->\\s* 'no garbage between comment and following tag', + minver => '2.4.69' }, + + # Comment stripping with extfix off (strip_comments=on, extfix=off) + { type => 'comment', path => 'comments_strip_no_extfix/comment_rewrite.html', + pattern => '', negate => 1, desc => 'comment stripped with extfix off', + minver => '2.4.69' }, + { type => 'comment', path => 'comments_strip_no_extfix/comment_rewrite.html', + pattern => '', negate => 1, desc => 'inline comment stripped with extfix off', + minver => '2.4.69' }, + { type => 'url_rewrite', path => 'comments_strip_no_extfix/comment_rewrite.html', + pattern => 'http://b\\.example\\.com/static/images/favicon\\.png', desc => 'URL rewritten with comments stripped, extfix off', + minver => '2.4.69' }, + { type => 'url_rewrite', path => 'comments_strip_no_extfix/comment_rewrite.html', + pattern => 'http://b\\.example\\.com/static/plugins/fontawesome-free/css/all\\.min\\.css', + desc => 'URL after stripped comment rewritten correctly, extfix off', + minver => '2.4.69' }, + + # Comment-after-rewrite with extfix on + # With extfix, pcomment accumulates into the varbuf but pstartElement + # resets it for attribute processing, so comments between elements + # are dropped. Verify URLs are still rewritten and no garbage appears. + { type => 'url_rewrite', path => 'comment_rewrite_extfix/comment_rewrite.html', + pattern => 'http://b\\.example\\.com/static/images/favicon\\.png', desc => 'URL rewritten with extfix on', + minver => '2.4.69' }, + { type => 'url_rewrite', path => 'comment_rewrite_extfix/comment_rewrite.html', + pattern => 'http://b\\.example\\.com/static/plugins/fontawesome-free/css/all\\.min\\.css', + desc => 'URL after comment rewritten with extfix on', + minver => '2.4.69' }, + { type => 'url_rewrite', path => 'comment_rewrite_extfix/comment_rewrite.html', + pattern => 'http://b\\.example\\.com/page1\\.html', desc => 'body URL rewritten with extfix on', + minver => '2.4.69' }, + # Multiple URL maps tests { type => 'url_rewrite', path => 'multiple_maps/multiple_maps.html', pattern => 'http://new-a\\.example\\.com/page1\\.html', desc => 'first URL map' }, @@ -165,6 +214,11 @@ my @tests = ( pattern => 'http://new-d\\.example\\.com/page3\\.html', desc => 'third URL map' }, ); +# Filter out tests which require a newer httpd version +@tests = grep { + !$_->{minver} || have_min_apache_version($_->{minver}) +} @tests; + # Calculate total number of tests my $total_tests = 0; foreach my $t (@tests) {