httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 49642] mod_rewrite mistakes encoded question mark as path/query string separator
Date Thu, 29 Mar 2012 15:32:04 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=49642

--- Comment #2 from Rainer Canavan <rainer-apache@7val.com> 2012-03-29 15:32:04 UTC
---
I think I have just stumbled upon the same problem. I have a file with a '?' in
its name that I want to acccess via rewrite rules, because it used to be in
/old, but is now in /new. I can work around this in this simple case by just
using an equivalent Alias statement.

The RewriteRule is

RewriteRule ^\/\/?old\/(.*)$ /tmp/new/$1 [T=text/plain,L,NE]

Just checking that the rule works with a "normal" file "foo" with contents "foo
foo":

curl http://172.28.51.128:11003/old/foo
172.28.51.128 - - [29/Mar/2012:15:36:14 +0200]
[172.28.51.128/sid#8611b58][rid#89faec8/initial] (2) init rewrite engine with
requested uri /old/foo
172.28.51.128 - - [29/Mar/2012:15:36:14 +0200]
[172.28.51.128/sid#8611b58][rid#89faec8/initial] (3) applying pattern
'^\/\/?old\/(.*)$' to uri '/old/foo'
172.28.51.128 - - [29/Mar/2012:15:36:14 +0200]
[172.28.51.128/sid#8611b58][rid#89faec8/initial] (2) rewrite '/old/foo' ->
'/tmp/new/foo'
172.28.51.128 - - [29/Mar/2012:15:36:14 +0200]
[172.28.51.128/sid#8611b58][rid#89faec8/initial] (2) remember /tmp/new/foo to
have MIME-type 'text/plain'
172.28.51.128 - - [29/Mar/2012:15:36:14 +0200]
[172.28.51.128/sid#8611b58][rid#89faec8/initial] (2) local path result:
/tmp/new/foo
172.28.51.128 - - [29/Mar/2012:15:36:14 +0200]
[172.28.51.128/sid#8611b58][rid#89faec8/initial] (1) go-ahead with /tmp/new/foo
[OK]
172.28.51.128 - - [29/Mar/2012:15:36:14 +0200]
[172.28.51.128/sid#8611b58][rid#89faec8/initial] (1) force filename
/tmp/new/foo to have MIME-type 'text/plain'
foo foo

The file named "bar?bar" (results with or without QSA  or NE are identical):
curl http://172.28.51.128:11003/old/bar%3Fbar
172.28.51.128 - - [29/Mar/2012:15:36:23 +0200]
[172.28.51.128/sid#8611b58][rid#89fced0/initial] (2) init rewrite engine with
requested uri /old/bar?bar
172.28.51.128 - - [29/Mar/2012:15:36:23 +0200]
[172.28.51.128/sid#8611b58][rid#89fced0/initial] (3) applying pattern
'^\/\/?old\/(.*)$' to uri '/old/bar?bar'
172.28.51.128 - - [29/Mar/2012:15:36:23 +0200]
[172.28.51.128/sid#8611b58][rid#89fced0/initial] (2) rewrite '/old/bar?bar' ->
'/tmp/new/bar?bar'
172.28.51.128 - - [29/Mar/2012:15:36:23 +0200]
[172.28.51.128/sid#8611b58][rid#89fced0/initial] (3) split uri=/tmp/new/bar?bar
-> uri=/tmp/new/bar, args=bar
172.28.51.128 - - [29/Mar/2012:15:36:23 +0200]
[172.28.51.128/sid#8611b58][rid#89fced0/initial] (2) remember /tmp/new/bar to
have MIME-type 'text/plain'
172.28.51.128 - - [29/Mar/2012:15:36:23 +0200]
[172.28.51.128/sid#8611b58][rid#89fced0/initial] (2) local path result:
/tmp/new/bar
172.28.51.128 - - [29/Mar/2012:15:36:23 +0200]
[172.28.51.128/sid#8611b58][rid#89fced0/initial] (1) go-ahead with /tmp/new/bar
[OK]
172.28.51.128 - - [29/Mar/2012:15:36:23 +0200]
[172.28.51.128/sid#8611b58][rid#89fced0/initial] (1) force filename
/tmp/new/bar to have MIME-type 'text/plain'
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /old/bar?bar was not found on this server.</p>
</body></html>

A file named "baz?baz" in directory /new2 in the document root works as
expected:
curl http://172.28.51.128:11003/new2/baz%3Fbaz
172.28.51.128 - - [29/Mar/2012:15:37:23 +0200]
[172.28.51.128/sid#8611b58][rid#8a04ef0/initial] (2) init rewrite engine with
requested uri /new2/baz?baz
172.28.51.128 - - [29/Mar/2012:15:37:23 +0200]
[172.28.51.128/sid#8611b58][rid#8a04ef0/initial] (3) applying pattern
'^\/\/?old\/(.*)$' to uri '/new2/baz?baz'
172.28.51.128 - - [29/Mar/2012:15:37:23 +0200]
[172.28.51.128/sid#8611b58][rid#8a04ef0/initial] (3) applying pattern '.' to
uri '/new2/baz?baz'
172.28.51.128 - - [29/Mar/2012:15:37:23 +0200]
[172.28.51.128/sid#8611b58][rid#8a04ef0/initial] (4) RewriteCond:
input='curl/7.24.0 (i686-pc-linux-gnu) libcurl/7.24.0 OpenSSL/0.9.8u
zlib/1.2.5' pattern='Apache \(internal dummy connection\)' => not-matched
172.28.51.128 - - [29/Mar/2012:15:37:23 +0200]
[172.28.51.128/sid#8611b58][rid#8a04ef0/initial] (1) pass through /new2/baz?baz
baz baz

Adding [B] to the flags doesn't have the desired results either - it's actually
worse, because '/' would get encoded to %2F, making directories inaccessible:
curl http://172.28.51.128:11003/old/bar%3Fbar
172.28.51.128 - - [29/Mar/2012:15:39:39 +0200]
[172.28.51.128/sid#847f6b0][rid#8a04eb0/initial] (2) init rewrite engine with
requested uri /old/bar?bar
172.28.51.128 - - [29/Mar/2012:15:39:39 +0200]
[172.28.51.128/sid#847f6b0][rid#8a04eb0/initial] (3) applying pattern
'^\/\/?old\/(.*)$' to uri '/old/bar?bar'
172.28.51.128 - - [29/Mar/2012:15:39:39 +0200]
[172.28.51.128/sid#847f6b0][rid#8a04eb0/initial] (5) escaping backreference
'bar?bar' to 'bar%3fbar'
172.28.51.128 - - [29/Mar/2012:15:39:39 +0200]
[172.28.51.128/sid#847f6b0][rid#8a04eb0/initial] (2) rewrite '/old/bar?bar' ->
'/tmp/new/bar%3fbar'
172.28.51.128 - - [29/Mar/2012:15:39:39 +0200]
[172.28.51.128/sid#847f6b0][rid#8a04eb0/initial] (2) remember
/tmp/new/bar%3fbar to have MIME-type 'text/plain'
172.28.51.128 - - [29/Mar/2012:15:39:39 +0200]
[172.28.51.128/sid#847f6b0][rid#8a04eb0/initial] (2) local path result:
/tmp/new/bar%3fbar
172.28.51.128 - - [29/Mar/2012:15:39:39 +0200]
[172.28.51.128/sid#847f6b0][rid#8a04eb0/initial] (1) go-ahead with
/tmp/new/bar%3fbar [OK]
172.28.51.128 - - [29/Mar/2012:15:39:39 +0200]
[172.28.51.128/sid#847f6b0][rid#8a04eb0/initial] (1) force filename
/tmp/new/bar%3fbar to have MIME-type 'text/plain'
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /old/bar?bar was not found on this server.</p>
</body></html>

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


Mime
View raw message