Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2007-07-29 21:27:10 +0400
committerIgor Sysoev <igor@sysoev.ru>2007-07-29 21:27:10 +0400
commit567f8f61f73323f83fedba1a1e2879aa616da52d (patch)
tree3aff8c6826ec738bb838d8d595e0c5dac6afd1b2 /src/http/modules
parentd44b42f0bf780b398ff96da3eca0727769bc68fa (diff)
r1333, r1334 merge:
omit unnecessary code, escape space, etc in $memcached_key
Diffstat (limited to 'src/http/modules')
-rw-r--r--src/http/modules/ngx_http_memcached_module.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/http/modules/ngx_http_memcached_module.c b/src/http/modules/ngx_http_memcached_module.c
index ffd872b44..f7205418c 100644
--- a/src/http/modules/ngx_http_memcached_module.c
+++ b/src/http/modules/ngx_http_memcached_module.c
@@ -226,6 +226,7 @@ static ngx_int_t
ngx_http_memcached_create_request(ngx_http_request_t *r)
{
size_t len;
+ uintptr_t escape;
ngx_buf_t *b;
ngx_chain_t *cl;
ngx_http_memcached_ctx_t *ctx;
@@ -242,10 +243,9 @@ ngx_http_memcached_create_request(ngx_http_request_t *r)
return NGX_ERROR;
}
- len = sizeof("get ") - 1 + vv->len + sizeof(CRLF) - 1;
- if (vv->len) {
- len += 1 + vv->len;
- }
+ escape = 2 * ngx_escape_uri(NULL, vv->data, vv->len, NGX_ESCAPE_MEMCACHED);
+
+ len = sizeof("get ") - 1 + vv->len + escape + sizeof(CRLF) - 1;
b = ngx_create_temp_buf(r->pool, len);
if (b == NULL) {
@@ -268,7 +268,13 @@ ngx_http_memcached_create_request(ngx_http_request_t *r)
ctx->key.data = b->last;
- b->last = ngx_copy(b->last, vv->data, vv->len);
+ if (escape == 0) {
+ b->last = ngx_copy(b->last, vv->data, vv->len);
+
+ } else {
+ b->last = (u_char *) ngx_escape_uri(b->last, vv->data, vv->len,
+ NGX_ESCAPE_MEMCACHED);
+ }
ctx->key.len = b->last - ctx->key.data;