diff options
author | root <root@rbsd.ankarstrom.se> | 2021-04-26 19:33:46 +0000 |
---|---|---|
committer | root <root@rbsd.ankarstrom.se> | 2021-04-26 19:33:46 +0000 |
commit | dd107ea3d822f14f08198135ae2fc5b3b1d454b6 (patch) | |
tree | c72f7e27c099aee3670ab4afcd53a9f4dc25c2ca /t | |
parent | e1c7d5442ca1d3bd67c200d2dbd94bd0e40e72bd (diff) | |
download | Apache-Inject-dd107ea3d822f14f08198135ae2fc5b3b1d454b6.tar.gz |
Fix regex bug, support HTML comments
I added \s* after <body> to match any potential newline (and, for
good measure, whitespace) after <body>. One would usually rather
have this:
<body>
My header
than this:
<body>My header
Diffstat (limited to 't')
-rw-r--r-- | t/basic.t | 30 |
1 files changed, 20 insertions, 10 deletions
@@ -5,7 +5,7 @@ use Apache::Test; use Apache::TestUtil; use Apache::TestRequest qw/GET_BODY/; -BEGIN { plan tests => 7; } +BEGIN { plan tests => 9; } # Prepare environment @@ -50,15 +50,6 @@ overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '<head>-ful head'; -overwrite 't/htdocs/subdir/.htaccess', <<CONF; -Inject head.html -CONF - -@body = ("This is a test page.\n"); -overwrite 't/htdocs/subdir/test.html', @body; -ok GET_BODY('/subdir/test.html'), "$head${body[0]}", - 'different injection in subdirectory'; - @body = ("<html>\n", "This is a test page.\n", "</html>\n"); overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot${body[2]}", @@ -74,6 +65,25 @@ overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '<!doctype> with leading newline'; +@body = ("<!-- quirks mode -->\n<!doctype html><!-- test -->\n", "This is a test page.\n"); +overwrite 't/htdocs/test.html', @body; +ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", + 'comments in <head>'; + +@body = ("<body>\n", "This is a test page.\n"); +overwrite 't/htdocs/test.html', @body; +ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", + 'document with <body>'; + +overwrite 't/htdocs/subdir/.htaccess', <<CONF; +Inject head.html +CONF + +@body = ("This is a test page.\n"); +overwrite 't/htdocs/subdir/test.html', @body; +ok GET_BODY('/subdir/test.html'), "$head${body[0]}", + 'different injection in subdirectory'; + overwrite 't/htdocs/.htaccess', <<CONF; Inject - head.html CONF |