From dd107ea3d822f14f08198135ae2fc5b3b1d454b6 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 26 Apr 2021 19:33:46 +0000 Subject: Fix regex bug, support HTML comments I added \s* after to match any potential newline (and, for good measure, whitespace) after . One would usually rather have this: My header than this: My header --- README | 50 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 11 deletions(-) (limited to 'README') diff --git a/README b/README index f8ab8ce..1f396ca 100644 --- a/README +++ b/README @@ -4,11 +4,23 @@ NAME SYNOPSIS LoadModule perl_module libexec/apache24/mod_perl.so PerlLoadModule Apache::Inject - DocumentRoot /uar/local/www/apache24/data + DocumentRoot /usr/local/www/apache24/data + + # Inject both header and footer on all pages on the server Inject head.html foot.html + + # Inject only header on pages under /blog + Inject head.html + + + + # Inject only footer on pages named index.html + Inject - foot.html + + DESCRIPTION Apache::Inject is a mod_perl module that adds an Apache directive called Inject. @@ -69,6 +81,22 @@ INSTALLATION relevant if you install Apache::Inject via App::Cpan, which normally runs as root. +SYNTAX + The Inject directive takes one or two arguments: + + Inject HEADER_FILE [FOOTER_FILE] + + Each argument can consist of one of two things: + + 1. the path to a file relative to the document root, or + 2. a single hyphen ("-"), signifying the absence of an argument. + + Passing a hyphen as the first argument disables the header, and passing + a hyphen as the second argument disables the footer. + + If you leave out the second argument, then it is implicitly equivalent + to a hyphen. + OPERATION Behind the scenes, the Inject directive works as an alias for PerlResponseHandler and PerlSetVar. For example, "Inject head.html @@ -86,6 +114,16 @@ OPERATION well as the contents of the "InjectHeader" and "InjectFooter" files, concatenates them intelligently and prints their combined contents. +CAVEATS + Apache::Inject::Handler uses regular expressions to determine the proper + location of the injected header. It supports all valid HTML. However, it + does not take into account that embedded CSS and JavaScript code can + contain strings that look like valid opening and closing HTML tags. + + On FreeBSD, you may need to enable the accf_http kernel module in order + for the tests to work. Note that Apache::Inject works fine without the + module; it is only the tests that require it. + DIAGNOSTICS Apache::Inject and Apache::Inject::Handler log all errors and warnings to the Apache log file. Below is a list of all issued errors and @@ -95,11 +133,6 @@ DIAGNOSTICS this means that it also declines the request, letting Apache handle it as it would if the Inject directive were not used. - Error: Argument cannot be a single space - In the current implementation, the file names given to Inject are - not allowed to consist solely of a single space, as this is a - special value signifying the absence of an argument. - Error: InjectHead/InjectFoot should not begin with slash, as it is already always relative to document root The paths given to Inject are always relative to the document root, @@ -122,11 +155,6 @@ DIAGNOSTICS This warning is issued if Apache::Inject::Handler for some reason cannot retrieve the current document root from Apache. -CAVEATS - On FreeBSD, you may need to enable the accf_http kernel module in order - for the tests to work. Note that Apache::Inject works fine without the - module; it is only the tests that require it. - AUTHOR John Ankarström, -- cgit v1.2.3