aboutsummaryrefslogtreecommitdiff
path: root/Inject
diff options
context:
space:
mode:
Diffstat (limited to 'Inject')
-rw-r--r--Inject/Handler.pm27
1 files changed, 15 insertions, 12 deletions
diff --git a/Inject/Handler.pm b/Inject/Handler.pm
index adeec57..98d4713 100644
--- a/Inject/Handler.pm
+++ b/Inject/Handler.pm
@@ -8,17 +8,20 @@ use Apache2::RequestUtil ();
use Apache2::Const qw/OK DECLINED/;
my $doc = qr{
- (?<head> <head[^>*]>.*?</head>
- |
- ( <title[^>]*>.*?</title>
- | <base[^>]*>
- | <meta[^>]*>
- | <link[^>]*>
- | <object[^>]*>.*?</object>
- | <style[^>]*>.*?</style> # n.b.
- | <script[^>]*>.*?</script> # n.b.
- | <noscript[^>]*>.*?</noscript> # n.b.!
- )+ )
+ (?<head> \s* # common way to trigger quirks mode
+ (<!doctype[^>]*>)? \s*
+ ( <head[^>]*>.*?</head> \s*
+ | ( <title[^>]*>.*?</title> \s*
+ | <base[^>]*> \s*
+ | <meta[^>]*> \s*
+ | <link[^>]*> \s*
+ | <object[^>]*>.*?</object> \s*
+ | <style[^>]*>.*?</style> \s* # n.b.
+ | <script[^>]*>.*?</script> \s* # n.b.
+ | <noscript[^>]*>.*?</noscript> \s* # n.b.!
+ )+
+ )
+ )?
(?<body> .* )
}xms;
@@ -29,7 +32,7 @@ sub handler {
my $content = ${$r->slurp_filename};
return DECLINED if not $content =~ /$doc/;
- print $+{head};
+ print $+{head} if $+{head};
print "Injection 1\n";
print $+{body};
print "Injection 2\n";