From 1a6208051f5a219c7783cfa8910496dcff6faec8 Mon Sep 17 00:00:00 2001 From: Vasiliy Soshnikov Date: Mon, 15 Apr 2019 22:31:59 +0300 Subject: [PATCH] #120 fixed & add tests. Update (C) dates. --- src/debug.h | 2 +- src/json_encoders.c | 2 +- src/json_encoders.h | 2 +- src/ngx_http_tnt_module.c | 5 ++--- src/ngx_http_tnt_version.h | 4 ++-- src/ngx_http_tnt_version.h.in | 2 +- src/tp_ext.h | 2 +- src/tp_transcode.c | 2 +- src/tp_transcode.h | 2 +- t/ngx_confs/tnt_server_test.conf | 8 +++++++- t/run_all.sh | 7 ++++++- t/test.lua | 4 ++++ t/v27_features.py | 22 ++++++++++++++++++++++ 13 files changed, 50 insertions(+), 14 deletions(-) create mode 100755 t/v27_features.py diff --git a/src/debug.h b/src/debug.h index e7c786a..ccc4b9e 100644 --- a/src/debug.h +++ b/src/debug.h @@ -27,7 +27,7 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Copyright (C) 2015-2018 Tarantool AUTHORS: + * Copyright (C) 2015-2019 Tarantool AUTHORS: * please see AUTHORS file. */ diff --git a/src/json_encoders.c b/src/json_encoders.c index 360f8f2..ffbb2dd 100644 --- a/src/json_encoders.c +++ b/src/json_encoders.c @@ -27,7 +27,7 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Copyright (C) 2016 - 2018 Tarantool AUTHORS: + * Copyright (C) 2016-2019 Tarantool AUTHORS: * please see AUTHORS file. */ diff --git a/src/json_encoders.h b/src/json_encoders.h index dab7e12..a7e8fe9 100644 --- a/src/json_encoders.h +++ b/src/json_encoders.h @@ -27,7 +27,7 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Copyright (C) 2016 - 2018 Tarantool AUTHORS: + * Copyright (C) 2016-2019 Tarantool AUTHORS: * please see AUTHORS file. */ diff --git a/src/ngx_http_tnt_module.c b/src/ngx_http_tnt_module.c index ec772f0..a061c4f 100644 --- a/src/ngx_http_tnt_module.c +++ b/src/ngx_http_tnt_module.c @@ -27,11 +27,10 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Copyright (C) 2015-2018 Tarantool AUTHORS: + * Copyright (C) 2015-2019 Tarantool AUTHORS: * please see AUTHORS file. */ - #include #include #include @@ -1616,7 +1615,7 @@ ngx_http_tnt_urldecode(ngx_http_request_t *r, ngx_str_t *src) c = src->data[s++]; - if (c == '%' && (ngx_uint_t) (s + 2) < src->len) { + if (c == '%' && (ngx_uint_t) (s + 2) <= src->len) { u_char c2 = src->data[s++]; u_char c3 = src->data[s++]; diff --git a/src/ngx_http_tnt_version.h b/src/ngx_http_tnt_version.h index f72bad3..78c2716 100644 --- a/src/ngx_http_tnt_version.h +++ b/src/ngx_http_tnt_version.h @@ -27,13 +27,13 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Copyright (C) 2015-2018 Tarantool AUTHORS: + * Copyright (C) 2015-2019 Tarantool AUTHORS: * please see AUTHORS file. */ #ifndef NGX_HTTP_TNT_VERSION_H #define NGX_HTTP_TNT_VERSION_H 1 -#define NGX_HTTP_TNT_MODULE_VERSION_STRING "v2.7" +#define NGX_HTTP_TNT_MODULE_VERSION_STRING "v2.7.1" #endif diff --git a/src/ngx_http_tnt_version.h.in b/src/ngx_http_tnt_version.h.in index ecf133c..39069ac 100644 --- a/src/ngx_http_tnt_version.h.in +++ b/src/ngx_http_tnt_version.h.in @@ -27,7 +27,7 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Copyright (C) 2015-2018 Tarantool AUTHORS: + * Copyright (C) 2015-2019 Tarantool AUTHORS: * please see AUTHORS file. */ diff --git a/src/tp_ext.h b/src/tp_ext.h index 04f11bf..4ba85a6 100644 --- a/src/tp_ext.h +++ b/src/tp_ext.h @@ -27,7 +27,7 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Copyright (C) 2015-2018 Tarantool AUTHORS: + * Copyright (C) 2015-2019 Tarantool AUTHORS: * please see AUTHORS file. */ diff --git a/src/tp_transcode.c b/src/tp_transcode.c index f137a8c..b945620 100644 --- a/src/tp_transcode.c +++ b/src/tp_transcode.c @@ -27,7 +27,7 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Copyright (C) 2015-2018 Tarantool AUTHORS: + * Copyright (C) 2015-2019 Tarantool AUTHORS: * please see AUTHORS file. */ diff --git a/src/tp_transcode.h b/src/tp_transcode.h index 3ed3670..f8af0d2 100644 --- a/src/tp_transcode.h +++ b/src/tp_transcode.h @@ -27,7 +27,7 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Copyright (C) 2015-2018 Tarantool AUTHORS: + * Copyright (C) 2015-2019 Tarantool AUTHORS: * please see AUTHORS file. */ diff --git a/t/ngx_confs/tnt_server_test.conf b/t/ngx_confs/tnt_server_test.conf index b025879..6b4a7bb 100644 --- a/t/ngx_confs/tnt_server_test.conf +++ b/t/ngx_confs/tnt_server_test.conf @@ -1,7 +1,7 @@ + http { autoindex off; - access_log off; include mime.types; default_type application/octet-stream; @@ -455,5 +455,11 @@ http { } tnt_pass tnt; } + location /issue_120 { + tnt_pass_http_request on parse_args unescape; + tnt_http_rest_methods all; + tnt_http_methods all; + tnt_pass tnt; + } } } diff --git a/t/run_all.sh b/t/run_all.sh index a55ad39..6559db5 100755 --- a/t/run_all.sh +++ b/t/run_all.sh @@ -30,6 +30,9 @@ for i in {1..10}; do $WORK_DIR/v26_features.py 1> /dev/null || ( echo "[-] $WORK_DIR/v26_features.py failed" && exit 1 ) + $WORK_DIR/v27_features.py 1> /dev/null || ( + echo "[-] $WORK_DIR/v26_features.py failed" && exit 1 + ) done echo '[+] OK' @@ -64,7 +67,9 @@ for i in {1..3}; do #$WORK_DIR/v26_features.py 1> /dev/null || ( # echo "[-] $WORK_DIR/v26_features.py failed" && exit 1 # ) - + $WORK_DIR/v27_features.py 1> /dev/null || ( + echo "[-] $WORK_DIR/v26_features.py failed" && exit 1 + ) clients_pids="$clients_pids $!" done for job in $clients_pids; do diff --git a/t/test.lua b/t/test.lua index 92db5b7..9ff3e7f 100755 --- a/t/test.lua +++ b/t/test.lua @@ -192,6 +192,10 @@ function issue_108(req) return req end +function issue_120(request) + return request +end + -- CFG box.cfg { log_level = 5, diff --git a/t/v27_features.py b/t/v27_features.py new file mode 100755 index 0000000..343f677 --- /dev/null +++ b/t/v27_features.py @@ -0,0 +1,22 @@ +#!/usr/bin/python +# -_- encoding: utf8 -_- + +import sys +import time +sys.path.append('./t') +from http_utils import * + +please_unescape_it = BASE_URL + '/issue_120/' + +print ('[+] unescape regression test') +args = {'arg1': 1, 'arg2': 'somestring'} +result = get_success(please_unescape_it + '19UM|SMSO/a%7Cx%3Db', args, {}) +assert(result['uri'] == '/issue_120/19UM|SMSO/a|x=b?arg1=1&arg2=somestring'), \ + "expected result" +print ('[+] OK') + +print ('[+] issue 120') +result = get_success(please_unescape_it + '%7B%7D', {}, {}) +assert(result['uri'] == '/issue_120/{}'), "expected result" +print ('[+] OK') +