Timing Sequence of Unescaping mod_rewrite

This is a discussion on Timing Sequence of Unescaping mod_rewrite within the Apache Web Server forums, part of the Web Server and Related Forums category; Got some weird results from mod_rewrite, and it had nothing to do with regular expressions; I was hoping someone could ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-16-2006
walt.stoneburner@gmail.com
 
Posts: n/a
Default Timing Sequence of Unescaping mod_rewrite

Got some weird results from mod_rewrite, and it had nothing to do with
regular expressions; I was hoping someone could explain to me what I
was witnessing.

For the sake of simplicity, let's say I'm trying to turn this ugly, if
not illegal url:
http://www.myserver.com/http://www.napkincomics.com/
Into:
myscript.php?url=http://www.napkincomics.com/

The rule I'm using to do this:
RewriteRule ^(http.*)$ myscript.php?URL=$1 [L]

And, for the most part, it works. PHP's $_REQUEST['URL'] returns a
value.

Now, here comes the weirdness I'd like to get explained:

1) The string value that gets return for the example above is:
http:/www.napkincomics.com/

Specifically, note that there is only _one_ slash, not _two_. It's as
if everything after the host is treated as a directory, and Apache is
helping me out by compressing // into /.

My thought was that if I did a mod_rewrite and pushed the url into a
legit form, where it was being passed a parameter, not a path, this
kind of thing wouldn't happen. In short, I'd get there before that
kind of damage would be done.

2) So, in trying to fake it out, I use %2F so that I could pass a slash
in much the same way one passes %20 to pass a space. However in this
case the regular expression doesn't match and the rewrite rule doesn't
fire.

I can't figure out why that'd be. The logs say that it's trying to
access /http://www.napkincomics.com/ on the local server. It's as if
the unescaping happens before the mod_rewrite rule.


Is there any way to take exactly what the user passed to the server and
manipulate it well before any of this other processing goes in?

Thanks,
Walt Stoneburner
wls@wwco.com

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:35 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0