Project

General

Profile

Feature #443

[PATCH] mod_redirect: Add support for url-encoding backreferences, map %%n->%n, $$n->$n

Added by Anonymous almost 13 years ago. Updated 3 months ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
mod_redirect
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
Missing in 1.5.x:

Description

Attached is a simple user-contributed (e.g. no guarantees) patch to expand the capabilities of mod_redirect for lighttpd 1.4.8.

It adds two features:

  • optional url-encoding for backreferences
  • allow backreference character usage without substituting a backref.

Here is an example of the first case:

Let's say that you want to map the specified URL into a CGI argument, but you want it to be escaped properly --


 url.redirect = ( "^(.*)$" =>
                  "/view?path=$!1" 

If a user requests "http://example.com/special/documents?foo=bar", they will be redirected to "http://example.com/view?path=%2Fspecial%2Fdocuments%3Ffoo%3Dbar".

Now let's say you want to include an absolute address so that the user is redirected to a different site, http://2.example.com. You would want the redirection to result in the following URL: "http://example.com/view?path=http%3A%2F%2F2.example.com%2Fspecial%2Fdocuments%3Ffoo%3Dbar".

The second change allows you to do this with mod_redirect:


 url.redirect = ( "^(.*)$" =>
                  "http%%3A%%2F%%2F2.example.com/view?path=$!1" 

Using double percents, mod_redirect will no longer assume that the %3 in %%3A is a poor backreference and it will print out the desired single %.

--

Doh - it looks like I need to attach after I file the ticket. If I have a problem with it, I will put it on the wiki as an attachment.

-- will

mod_redirect_expansion-1.4.8.patch (2.61 KB) mod_redirect_expansion-1.4.8.patch mod_redirect url-encode and %%/$$ patch -- will Anonymous, 2006-01-06 08:44
ticket-443.patch (11.2 KB) ticket-443.patch moo, 2006-04-16 11:31

Related issues

Related to Bug #911: Need for URL encoding in mod_redirect and possibly mod_rewriteFixed

Actions

Associated revisions

Revision 255269d7 (diff)
Added by gstrauss 3 months ago

[mod_redirect,mod_rewrite] encoding options (fixes #443, fixes #911)

Provide means to encode redirect and rewrite backreference substitutions
In addition to $1 and %1, the following modifiers are now supported,
followed by the number for the backreference, e.g. ${esc:1}

${noesc:...}  no escaping
${esc:...} escape all non-alphanumeric - . _ ~ incl double-escape %
${escape:...} escape all non-alphanumeric - . _ ~ incl double-escape %
${escnde:...} escape all non-alphanumeric - . _ ~ but no double-esc %
${tolower:...}
${toupper:...}
%{noesc:...}
%{esc:...}
%{escape:...}
%{escnde:...}
%{tolower:...}
%{toupper:...}

Provide means to substitute URI parts without needing a regex match
(and can be preceded by encoding modifier,
e.g. ${tolower:url.authority})

${url.scheme}
${url.authority}
${url.port}
${url.path}
${url.query}
${qsa}        appends query string, if not empty

x-ref:
"[PATCH] mod_redirect: Add support for url-encoding backreferences, map %%n->%n, $$n->$n"
https://redmine.lighttpd.net/issues/443
"Need for URL encoding in mod_redirect and possibly mod_rewrite"
https://redmine.lighttpd.net/issues/911

History

#1

Updated by moo over 12 years ago

  • Status changed from New to Assigned

assign to me. applies to mod_rewrite too. anyone else have another character against the '!' ?

#2

Updated by moo over 12 years ago

patch pending

#3

Updated by moo about 11 years ago

cannot be done in 1.4.x unless r1094 is merged back to browser:branches1.4.x, need discussion for 1.5

#4

Updated by Anonymous almost 11 years ago

This site could really benefit from some, any, spam prevention.

#5

Updated by Anonymous over 10 years ago

Fixed spam changes

-- raja

#6

Updated by gstrauss over 2 years ago

  • Related to Bug #911: Need for URL encoding in mod_redirect and possibly mod_rewrite added
#7

Updated by gstrauss over 2 years ago

  • Assignee deleted (moo)
#8

Updated by gstrauss over 2 years ago

  • Target version deleted (1.5.0)
#9

Updated by gstrauss 5 months ago

  • Description updated (diff)
  • Status changed from Assigned to Patch Pending
  • Target version set to 1.4.50
#10

Updated by gstrauss 3 months ago

  • Status changed from Patch Pending to Fixed
  • % Done changed from 0 to 100
#11

Updated by gstrauss 3 months ago

Documentation for url-encoding backreferences can be found on mod_rewrite in section Extended Replacement Patterns

Also available in: Atom