diff options
Diffstat (limited to 'Inject')
-rw-r--r-- | Inject/Handler.pm | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Inject/Handler.pm b/Inject/Handler.pm new file mode 100644 index 0000000..adeec57 --- /dev/null +++ b/Inject/Handler.pm @@ -0,0 +1,40 @@ +package Apache::Inject::Handler; + +use strict; +use warnings; + +use Apache2::RequestRec (); +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.! + )+ ) + (?<body> .* ) +}xms; + +sub handler { + my $r = shift; + + return DECLINED if not $r->content_type eq 'text/html'; + + my $content = ${$r->slurp_filename}; + return DECLINED if not $content =~ /$doc/; + print $+{head}; + print "Injection 1\n"; + print $+{body}; + print "Injection 2\n"; + + return OK; +} + +1; |