﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	uname	nginx_version
564	map regex matching affects rewrite directive	Pascal Jungblut		"Using a regex in the `map` directive changes the capture groups in a rewrite directive. This happens only if the regex in `map` is matched. A minimal exampe config:


{{{
http {
        map $http_accept_language $lang {
                default en;
                 ~(de) de;
        }
        server {
                server_name test.local
                listen 80;
                rewrite ^/(.*)$ http://example.com/$lang/$1 permanent;
        }
}
}}}

Expected:

{{{
$ curl -sI http://test.local/foo | grep Location
Location: http://example.com/en/foo
$ curl -H ""Accept-Language: de"" -sI http://test.local/foo | grep Location
Location: http://example.com/de/foo
}}}


Actual:

{{{
$ curl -sI http://test.local/foo | grep Location
Location: http://example.com/en/foo
$ curl -H ""Accept-Language: de"" -sI http://test.local/foo | grep Location
Location: http://example.com/de/de
}}}

If I leave out the parentheses in `~(de) de;` (so it becomes `~de de;`), `$1` is simply empty:

{{{
$ curl -H ""Accept-Language: de"" -sI http://test.local/foo | grep Location
Location: http://example.com/de/
}}}"	defect	accepted	minor		nginx-core					FreeBSD freebsd 10.0-RELEASE FreeBSD 10.0-RELEASE #0 r260789: Thu Jan 16 22:34:59 UTC 2014     root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64	"nginx version: nginx/1.6.0
TLS SNI support enabled
configure arguments: --prefix=/usr/local/etc/nginx --with-cc-opt='-I /usr/local/include' --with-ld-opt='-L /usr/local/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin/nginx --pid-path=/var/run/nginx.pid --error-log-path=/var/log/nginx-error.log --user=www --group=www --http-client-body-temp-path=/var/tmp/nginx/client_body_temp --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi_temp --http-proxy-temp-path=/var/tmp/nginx/proxy_temp --http-scgi-temp-path=/var/tmp/nginx/scgi_temp --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi_temp --http-log-path=/var/log/nginx-access.log --with-http_stub_status_module --with-pcre --with-http_ssl_module"
