[PATH] Variable: setting $args should invalidate unparsed uri.
Yichun Zhang (agentzh)
agentzh at gmail.com
Thu Jan 23 20:16:48 UTC 2014
Hello!
A user of mine, rvsw, reported an issue in the $args builtin variable.
Setting $args does not change the r->valid_unparsed_uri flag so
modules like ngx_proxy might still use the unparsed URI even when the
$args has been assigned to a new value.
A minimal example that can reproduce this is as follows:
server {
listen 54123;
location = /t {
return 200 "args: $args";
}
}
server {
listen 8080;
location = /t {
set $args "foo=1&bar=2";
proxy_pass http://127.0.0.1:54123;
}
}
Querying localhost:8080/t should give
args: foo=1&bar=2
But we're getting
args:
with the current nginx core.
The patch attached to this email fixes this issue.
Thanks!
-agentzh
# HG changeset patch
# User Yichun Zhang <agentzh at gmail.com>
# Date 1390506359 28800
# Node ID 17186b98c235c07e94c64e5853689f790f173756
# Parent 4b50d1f299d8a69f3e3f7975132e1490352642fe
Variable: setting $args should invalidate unparsed uri.
diff -r 4b50d1f299d8 -r 17186b98c235 src/http/ngx_http_variables.c
--- a/src/http/ngx_http_variables.c Fri Jan 10 11:22:14 2014 -0800
+++ b/src/http/ngx_http_variables.c Thu Jan 23 11:45:59 2014 -0800
@@ -15,6 +15,8 @@
ngx_http_variable_value_t *v, uintptr_t data);
static void ngx_http_variable_request_set(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
+static void ngx_http_variable_request_args_set(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_request_get_size(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
static void ngx_http_variable_request_set_size(ngx_http_request_t *r,
@@ -218,7 +220,7 @@
NGX_HTTP_VAR_NOCACHEABLE, 0 },
{ ngx_string("args"),
- ngx_http_variable_request_set,
+ ngx_http_variable_request_args_set,
ngx_http_variable_request,
offsetof(ngx_http_request_t, args),
NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 },
@@ -647,6 +649,15 @@
static void
+ngx_http_variable_request_args_set(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data)
+{
+ r->valid_unparsed_uri = 0;
+ ngx_http_variable_request_set(r, v, data);
+}
+
+
+static void
ngx_http_variable_request_set(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data)
{
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nginx-1.5.8-setting_args_invalidates_uri.patch
Type: text/x-patch
Size: 1621 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20140123/7284e351/attachment.bin>
More information about the nginx-devel
mailing list