Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions t/conf/proxy.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,43 @@ Alias /modules/proxy/fcgi-uds-sethandler @SERVERROOT@/htdocs/modules/proxy/fcgi
ProxyPass http://@SERVERNAME@:@PORT@/modules/proxy_html
</Location>

# Comment-after-rewrite test (regression for garbage after
# comments following rewritten URLs)
<Location /modules/html_proxy/comment_rewrite>
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
</Location>

# Comment stripping with extfix off
<Location /modules/html_proxy/comments_strip_no_extfix>
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
</Location>

# Comment-after-rewrite with extfix on
<Location /modules/html_proxy/comment_rewrite_extfix>
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
</Location>

# Multiple URL maps test
<Location /modules/html_proxy/multiple_maps>
ProxyHTMLEnable on
Expand Down
14 changes: 14 additions & 0 deletions t/htdocs/modules/proxy_html/comment_rewrite.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Comment After Rewrite Test</title>
<link rel="shortcut icon" type="image/png" href="http://a.example.com/static/images/favicon.png">
<!-- Font Awesome Icons -->
<link rel="stylesheet" href="http://a.example.com/static/plugins/fontawesome-free/css/all.min.css">
</head>
<body>
<a href="http://a.example.com/page1.html">Link 1</a>
<!-- comment after link -->
<a href="http://a.example.com/page2.html">Link 2</a>
</body>
</html>
54 changes: 54 additions & 0 deletions t/modules/proxy_html.t
Original file line number Diff line number Diff line change
Expand Up @@ -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 => '<!-- Font Awesome Icons -->', 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 => '<!-- comment after link -->', desc => 'inline comment preserved after rewrite',
minver => '2.4.69' },
{ type => 'url_rewrite', path => 'comment_rewrite/comment_rewrite.html',
pattern => '-->\\s*<link', desc => '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 => '<!-- Font Awesome Icons -->', negate => 1, desc => 'comment stripped with extfix off',
minver => '2.4.69' },
{ type => 'comment', path => 'comments_strip_no_extfix/comment_rewrite.html',
pattern => '<!-- comment after link -->', 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' },
Expand All @@ -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) {
Expand Down
Loading