Welcome! Log In Create A New Profile

Advanced

[nginx] Proxy: escape explicit space in URI in default cache key.

Roman Arutyunyan
December 05, 2017 01:16PM
details: http://hg.nginx.org/nginx/rev/e8e19f5e0b8b
branches:
changeset: 7169:e8e19f5e0b8b
user: Roman Arutyunyan <arut@nginx.com>
date: Mon Nov 20 20:50:35 2017 +0300
description:
Proxy: escape explicit space in URI in default cache key.

If the flag space_in_uri is set, the URI in HTTP upstream request is escaped to
convert space to %20. However this flag is not checked while creating the
default cache key. This leads to different cache keys for requests
'/foo bar' and '/foo%20bar', while the upstream requests are identical.

Additionally, the change fixes background cache updates when the client URI
contains unescaped space. Default cache key in a subrequest is always based on
escaped URI, while the main request may not escape it. As a result, background
cache update subrequest may update a different cache entry.

diffstat:

src/http/modules/ngx_http_proxy_module.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 46ebff8c6396 -r e8e19f5e0b8b src/http/modules/ngx_http_proxy_module.c
--- a/src/http/modules/ngx_http_proxy_module.c Mon Nov 20 21:11:19 2017 +0300
+++ b/src/http/modules/ngx_http_proxy_module.c Mon Nov 20 20:50:35 2017 +0300
@@ -1095,7 +1095,7 @@ ngx_http_proxy_create_key(ngx_http_reque

loc_len = (r->valid_location && ctx->vars.uri.len) ? plcf->location.len : 0;

- if (r->quoted_uri || r->internal) {
+ if (r->quoted_uri || r->space_in_uri || r->internal) {
escape = 2 * ngx_escape_uri(NULL, r->uri.data + loc_len,
r->uri.len - loc_len, NGX_ESCAPE_URI);
} else {
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Proxy: escape explicit space in URI in default cache key.

Roman Arutyunyan 493 December 05, 2017 01:16PM



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

Online Users

Guests: 285
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