Bug 38448 - mod_proxy encodes ~ to %7E in Reverse Proxy mode
Summary: mod_proxy encodes ~ to %7E in Reverse Proxy mode
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_proxy (show other bugs)
Version: 2.0.55
Hardware: PC FreeBSD
: P2 minor (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2006-01-30 16:27 UTC by Stijn Hoop
Modified: 2007-08-31 06:28 UTC (History)
0 users



Attachments
patch to reserve ~ character in mod_proxy (376 bytes, patch)
2006-01-30 16:28 UTC, Stijn Hoop
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stijn Hoop 2006-01-30 16:27:39 UTC
In a reverse proxy setup I encountered a problem with user directories; it
seemed like every now and then users got redirected to http://host/%7Euser
instead of the correct http://host/~user. After some debugging I figured out
that the frontend mod_proxy was "canonicalizing" URLs, thereby encoding ~ as
%7E. This would not be an issue but for lots of backend server software that
relied on the URL passed to the backend server to be the same as the one the
user saw in their browsers. Now, this is of course a bad assumption *but* I
don't really know why the canonicalization happens in the first place, or even
why ~ is not considered a safe character.

I have attached a patch that simply adds '~' to the set of "reserved" characters
for modules/proxy/proxy_util.c:ap_proxy_canonenc. It does the job on my site. Is
there any reason not to apply it?

Note: I tried to subscribe to apache-users@ to ask around for other people
experiencing this bug bug the list never confirmed my emails...
Comment 1 Stijn Hoop 2006-01-30 16:28:35 UTC
Created attachment 17536 [details]
patch to reserve ~ character in mod_proxy

Here is the trivial patch.
Comment 2 Stijn Hoop 2006-08-08 10:01:05 UTC
well.. guess nobody's interested either way?
Comment 3 Nick Kew 2006-08-08 12:48:20 UTC
(In reply to comment #2)
> well.. guess nobody's interested either way?

~ may or may not be a reserved character according to which edition of the RFC 
you read.  Encoding it as %7E is a safe option.

I don't see any strong reason to apply your patch (but feel free to try and 
convince me).  Neither do I see any reason to close this report - it's marked 
as PatchAvailable for the benefit of anyone who wants it.
Comment 4 Nick Kew 2006-08-08 23:33:18 UTC
I changed my mind since my previous comment, and I've committed this 
to /trunk/.  Thanks:-)
Comment 5 Stijn Hoop 2006-08-10 07:00:55 UTC
Many thanks! That's one less customized package to maintain!
Comment 6 Nick Kew 2007-08-31 06:28:30 UTC
Fixed in 2.2 branch (r571456).  Closing.