Bug 17918 - API method ap_escape_path_segment does not encode '&'
Summary: API method ap_escape_path_segment does not encode '&'
Status: CLOSED INVALID
Alias: None
Product: Apache httpd-1.3
Classification: Unclassified
Component: core (show other bugs)
Version: 1.3.27
Hardware: Sun other
: P3 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2003-03-12 15:19 UTC by Xavier Grosjean
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments
the modification as proposed in the bug description (2.83 KB, patch)
2003-03-12 15:24 UTC, Xavier Grosjean
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Xavier Grosjean 2003-03-12 15:19:31 UTC
The api method 'ap_escape_path_segment' does not URL-encode the '&' character.
This means that if you use it in a custom apache module, you will not be able 
to correctly encode an URL that contains parameter-value pairs separated 
with '&'. The '&' will be left unchanged, and passing this URL as a value of a 
parameter of another URL will lead to mistakingly take this unchanged '&' for a 
parameter-name separator of the new URL.

RFC 1738 says that ';', '/', '?' are reserved characters in the path and search 
components of an HTTP URL, but the BNF shows '&' as well.
It looks like the correct parameter-value separator should be ';' but we all 
know it's almost never the case (I think the CGI perl modules handles it, 
though).

The correction of this problem is rather simple:
in src/main/gen_test_char.c
replace (line 61 in 1.3.27 Solaris):
        if (!ap_isalnum(c) && !strchr("$-_.+!*'(),:@&=~", c)) {
with
        if (!ap_isalnum(c) && !strchr("$-_.+!*'(),:@=~", c)) {
and start the full compilation all over again.

The "test_char.h" generator (gen_test_char) will be modified, a new
test_char.h generated, and used in util.c with the needed values to have '&' 
url-encoded by 'ap_escape_path_segment' 

The 'ap_escape_path_segment' documentation, while short, says it is not used by 
apache. Witch is probably why this was not an issue until now...
Comment 1 Xavier Grosjean 2003-03-12 15:24:48 UTC
Created attachment 5289 [details]
the modification as proposed in the bug description
Comment 2 Jeff Trawick 2003-11-21 22:44:53 UTC
enabling the PatchAvailable keyword
updated doc on submitting patches is at http://httpd.apache.org/dev/patches.html
Comment 3 André Malo 2003-11-21 23:13:09 UTC
According to RFC 2616 which refers explicitly to RFC 2396, the & is not a
reserved character within path segments. See RFC 2396, section 3.3.