Welcome to WebmasterWorld Guest from 3.214.184.196

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

Using mod sed on both in/out filtering on same site

apache mod_sed filter

     
4:54 pm on Jun 23, 2016 (gmt 0)

New User

joined:June 23, 2016
posts: 3
votes: 0


Hi,

Using Apache 2.4.

I'm trying to use mod_sed with both input and output filters at the same time. I can only get the output filter on it's own to work:

<Location "/var/www">
AddOutputFilter Sed html
OutputSed "s/123/abc/g"
OutputSed "s/stuff/ffuts/g"
</Location>

I'd like to use an input filter too on the same site:

<Location "/var/www">
AddInputFilter Sed html
InputSed "s/abc/123/g"
InputSed "s/ffuts/stuff/g"
</Location>

...but only the output filter is being used. In fact, if I activate the input filter, it disables the output filter, so nothing then works.

I'd appreciate any pointers in getting this to work.

Thanks
Henry
6:14 pm on June 23, 2016 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15867
votes: 869


<tangent>
If it takes a while to get an answer, it's because most of us are still in 2.2. (So far, my host will only admit to "in the works" for 2.4, and I haven't upgraded MAMP.) And this one involves a brand-new mod; in fact I had to go look it up.
</tangent>

Do the input/output directives cancel each other sequentially? That is, if you have both an "input" and an "output" line, does the server only use the last one, whichever it may happen to be?

Does the input/output conflict happen only with Sed directives, or with any and all other stuff involving mod_mime?

Is the server otherwise perfectly happy to have two separate <Location> envelopes applying to the same location? (And why is it Location at all? Generally that's a last resort for when <Directory> can't be used.)

The object of these questions is to pin down the source of the trouble: root, mod_mime or mod_sed.
7:50 am on June 25, 2016 (gmt 0)

New User

joined:June 23, 2016
posts: 3
votes: 0


Thanks for the reply!

> Is the server otherwise perfectly happy to have two separate <Location> envelopes applying to the same location? (And why is it Location at all? Generally that's a last resort for when <Directory> can't be used.)

No idea on first question. Use of Location just happens to be the last one I tried. Directory also works, which I just confirmed.

I did config order tests and it looks like if both filters are active, then ONLY the last filter is used; the first is ignored.

I also tried using <Directory> on the first, and <Location> on the second, but the effect is the same - the first filter is always ignored and only the last is used.

Not sure about mod_mime's involvement - something you'd like me to test in this regard?
5:06 pm on June 25, 2016 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15867
votes: 869


Not sure about mod_mime's involvement

As I understand it, mod_mime is the one that actually processes the OutputFilter or InputFilter lines.

:: detour here to get a grip on the difference between AddBlahBlah/RemoveBlahBlah (mod_mime, requires an extension as third argument) and SetBlahBlah (core, no third argument) ::

mod_sed only gets involved if the specific filter is Sed. That's why it's important to find out if the server is willing to process both directives (AddInputFilter and AddOutputFilter) if mod_sed isn't involved. If yes, it's a mod_sed problem. If no, it's a mod_mime problem.

Did you at some point try putting both lines (Input and Output) into the same envelope, whether Location or Directory? That's to eliminate the possibility that it's a core syntax issue. (Personally I'd stick with Directory, unless you've got a bunch of complicated aliasing, such that Location is the only way to be sure you're meeting all requests.)

Docs say "Status: Experimental" for mod_sed in its entirety. Now there's a word you never want to see in official documentation ;) (It probably doesn't mean "experimental". It's probably got some arcane, technical, "Oh, that's all right then" meaning.)

A tutorial article on mod_sed, and why it is more powerful than simple string or regular expression search and replace
Really, this is getting more alarming by the minute.

This is all happening on an experimental site, right, not on your active production server? So we can continue trying things out without bringing everything crashing to the ground?

:: looking vaguely around for whitespace or someone like him ::
8:19 am on July 10, 2016 (gmt 0)

New User

joined:June 23, 2016
posts: 3
votes: 0


Sorry about the delay in responding - I've been away...

Cool, I now understand your point about mod_mime being the initiator for Addin/out.

1. It's a test site (getting ready for launch), so I can test to my hearts content.

2. damn - just saw "Status:Experimental" at [httpd.apache.org...] so you're right.

3. On:

Did you at some point try putting both lines (Input and Output) into the same envelope, whether Location or Directory? That's to eliminate the possibility that it's a core syntax issue. (Personally I'd stick with Directory, unless you've got a bunch of complicated aliasing, such that Location is the only way to be sure you're meeting all requests.)


I'll give that a try. I presume you're talking about:


<Location "/var/www">
AddOutputFilter Sed html
OutputSed "s/123/abc/g"
OutputSed "s/stuff/ffuts/g"

AddInputFilter Sed html
InputSed "s/abc/123/g"
InputSed "s/ffuts/stuff/g"
</Location>


I'll give that a swing and see what happens.