You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2010/08/12 21:07:46 UTC
DO NOT REPLY [Bug 49746] New: mod_rewrite urlencode option
https://issues.apache.org/bugzilla/show_bug.cgi?id=49746
Summary: mod_rewrite urlencode option
Product: Apache httpd-2
Version: 2.3-HEAD
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: mod_rewrite
AssignedTo: bugs@httpd.apache.org
ReportedBy: jhmartin@toger.us
I suggest adding a flag to mod_rewrite to optionally url-encode captured
values.
Something like:
RewriteRule /(.*)
/some/other/url=&target=http://www.example.com/handler?foo=bar&target=$1&zed=zee
[UE]
where UE causes the (.*) value to be urlencoded before being placed into $1.
This handles cases where you want to rewrite the request url into an argument
of another url, and the requested url might have a multivalue query string in
it.
Example:
http://www.example.com/foo/?bar=zed&foo=zee
becomes
http://www.example.com/handler?foo=bar&target=%2Ffoo%2F%3Fbar%3Dzed%26foo%3Dzee&zed=zee
--
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
DO NOT REPLY [Bug 49746] mod_rewrite urlencode option
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49746
Jason Martin <jh...@toger.us> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|WORKSFORME |
--- Comment #6 from Jason Martin <jh...@toger.us> 2010-08-25 13:34:31 EDT ---
I'm sorry, have to reopen again. Neither int:escape or [B] handle the case
where the original request had a query string, and I now want to package up the
entire original request and pass it in the query string.
Example:
/foo/bar?zed=zee&ivy=true Should be come
/some/other/url?target=/foo/bar%3Fzed=zee%26ivy=true, or something along those
lines.
With the current mechanisms, the & in the query string is not escaped by either
int:escape or [B] (as there is no way to backreference query_string), meaning
the servlet thinks everything after the first name/value pair is a separate
argument and not part of target.
RewriteMap escape int:escape
RewriteRule /(.*)
/some/url?resource=fibble&target=http://%{HTTP_HOST}/$1?${escape:%{QUERY_STRING}}
[B,PT,L]
(2) init rewrite engine with requested uri /foo/bar
(3) applying pattern '/(.*)' to uri '/foo/bar'
(5) escaping backreference 'foo/bar' to 'foo%2fbar'
(5) map lookup OK: map=escape key=zed=zee&ivy=true -> val=zed=zee&ivy=true
(2) rewrite '/foo/bar' ->
'/some/url?resource=fibble&target=http://127.0.0.1:26080/foo%2fbar?zed=zee&ivy=true'
(3) split
uri=/some/url?resource=fibble&target=http://127.0.0.1:26080/foo%2fbar?zed=zee&ivy=true
-> uri=/some/url,
args=resource=fibble&target=http://127.0.0.1:26080/foo%2fbar?zed=zee&ivy=true
(2) forcing '/some/url' to get passed through to next API URI-to-filename
handler
--
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
DO NOT REPLY [Bug 49746] mod_rewrite urlencode option
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49746
Jason Martin <jh...@toger.us> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P2 |P4
Status|RESOLVED |REOPENED
Resolution|WORKSFORME |
--- Comment #2 from Jason Martin <jh...@toger.us> 2010-08-12 16:24:06 EDT ---
This does not appear to work for escaping query-string arguments, as the & sign
is not being escaped:
(5) map lookup OK: map=escape key=foo=bar&zed=zee&fib/fib ->
val=foo=bar&zed=zee&fib/fib
This is with
Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/1.0.0
I'm using
RewriteMap escape int:escape
and
${escape:%{QUERY_STRING}} in the rewrite rule.
wget -O- "http://www.example.com/?foo=bar&zed=zee&fib/fib"
Perhaps there is use in adding another map function with a more comprehensive
translation list?
--
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
DO NOT REPLY [Bug 49746] mod_rewrite urlencode option
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49746
Jason Martin <jh...@toger.us> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |WORKSFORME
--- Comment #5 from Jason Martin <jh...@toger.us> 2010-08-25 12:44:56 EDT ---
Ah didn't see that (was looking at 2.0). Thank you.
--
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
DO NOT REPLY [Bug 49746] mod_rewrite urlencode option
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49746
--- Comment #3 from Jason Martin <jh...@toger.us> 2010-08-13 12:03:13 EDT ---
Since it looks like the escape map really just calls ap_escape_uri, which is a
macro for ap_escape_os_path; how about a htmlescape map that calls
ap_escape_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
DO NOT REPLY [Bug 49746] mod_rewrite urlencode option
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49746
Dan Poirier <po...@pobox.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |WORKSFORME
--- Comment #1 from Dan Poirier <po...@pobox.com> 2010-08-12 15:28:17 EDT ---
This feature is already available.
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#mapfunc
Look for the internal map for "escape".
--
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
DO NOT REPLY [Bug 49746] mod_rewrite urlencode option
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49746
--- Comment #4 from Bob Ionescu <bo...@googlemail.com> 2010-08-14 04:55:07 EDT ---
> where UE causes the (.*) value to be urlencoded before being placed into $1.
That's already done by the B flag.
--
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