| 1 | package Apache::HeavyCGI::UnmaskQuery; | ||
| 2 | use Apache::Constants qw(:common); | ||
| 3 | use constant AHU_DEBUG => 0; | ||
| 4 | use strict; | ||
| 5 | use vars qw($VERSION); | ||
| 6 | $VERSION = sprintf "%d.%03d", q$Revision: 1.11 $ =~ /(\d+)\.(\d+)/; | ||
| 7 | |||
| 8 | |||
| 9 | sub handler { | ||
| 10 | my($r) = @_; | ||
| 11 | my $uri = $r->uri; | ||
| 12 | if ( my($u1,$u2) = $uri =~ / ^ ([^?]+?) ; ([^?]*) $ /x ) { | ||
| 13 | $r->uri($u1); | ||
| 14 | # $u2 =~ s/%..//g; # just testing | ||
| 15 | $u2 =~ s/;/&/g if $u2 =~ /&/; # don't mix: bug in Apache::Request ? | ||
| 16 | $r->args($u2); | ||
| 17 | warn "UnmaskQuery(v$VERSION): u1[$u1]u2[$u2]" if AHU_DEBUG; | ||
| 18 | } elsif ($uri =~ /\?/) { | ||
| 19 | my $args = $r->args; | ||
| 20 | if ($args =~ /&/ and $args =~ s/;/&/g) { # don't mix! | ||
| 21 | $r->args($args); | ||
| 22 | warn "UnmaskQuery(v$VERSION): args[$args]" if AHU_DEBUG; | ||
| 23 | } else { | ||
| 24 | warn "UnmaskQuery(v$VERSION): nothing" if AHU_DEBUG; | ||
| 25 | } | ||
| 26 | } elsif ( my($u1,$u2) = $uri =~ m/^(.*?)%3[Bb](.*)$/ ) { | ||
| 27 | # protect against old proxies that escape volens nolens | ||
| 28 | $r->uri($u1); | ||
| 29 | $u2 =~ s/%3B/;/gi; | ||
| 30 | $u2 =~ s/%26/;/gi; # & | ||
| 31 | $u2 =~ s/%3D/=/gi; | ||
| 32 | $r->args($u2); | ||
| 33 | warn "UnmaskQuery(v$VERSION): oldproxy-u1[$u1]u2[$u2]" | ||
| 34 | if 1||AHU_DEBUG; | ||
| 35 | } | ||
| 36 | |||
| 37 | DECLINED; | ||
| 38 | } | ||
| 39 | |||
| 40 | 1; | ||
| 41 | |||
| 42 | __END__ |