Welcome! Log In Create A New Profile

Advanced

Re: Incorrect handling of "%2b" in rewrite directive

Maxim Dounin
October 09, 2013 12:04PM
Hello!

On Wed, Oct 09, 2013 at 06:54:08PM +0400, Dmitry Petrov wrote:

> Hi.
>
> To perform rewrite, nginx does ngx_unescape_uri and then ngx_escape_uri to
> pass request to backend. There is a problem with this functions: they both
> can't handler "+" propertly: ngx_escape_uri does not escape «+» character
>
> So when there is «%2b» sequence in rewrite command, it will be passed to
> backend as «+» where it SHOULD be interpreted as space character.
> I've attached a small patch that solved a problem for me.
>
> For testing I used
> location /foo {
> rewrite (.*) $1 break;
> proxy_pass http://localhost:1234;
> }
> + while true; do nc -l -p 1234; done — to watch what is really send to
> backend by nginx.

The "+" character has a special meaning only in query components.
It is allowed and has no special meaning in paths. That is, URLs
"http://example.com/foo+bar" and "http://example.com/foo%bbar" are
equivalent.

--
Maxim Dounin
http://nginx.org/en/donation.html

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Incorrect handling of "%2b" in rewrite directive Attachments

Dmitry Petrov 824 October 09, 2013 10:56AM

Re: Incorrect handling of "%2b" in rewrite directive

Maxim Dounin 695 October 09, 2013 12:04PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 218
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready