Skip to content

Commit

Permalink
Add args escaping if parse_args is on
Browse files Browse the repository at this point in the history
  • Loading branch information
dedok committed Feb 13, 2017
1 parent 07b4ad0 commit 494ce38
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
17 changes: 12 additions & 5 deletions src/ngx_http_tnt_handlers.c
Expand Up @@ -405,14 +405,16 @@ ngx_http_tnt_encode_query_args(
if (arg.value && value_len > 0) {

++(*args_items);
if (!tp_encode_str_map_item(tp,
(const char *)arg_begin,
arg.value - arg_begin - 1,
(const char *)arg.value, value_len))

if (ngx_http_tnt_encode_str_map_item(r, tlcf, tp,
arg_begin,
arg.value - arg_begin - 1,
arg.value,
value_len) != NGX_OK)
{
dd("parse args: tp_encode_str_map_item failed");
return NGX_ERROR;
}

}
arg_begin = ++arg.it;
}
Expand Down Expand Up @@ -516,6 +518,11 @@ ngx_http_tnt_get_request_data(ngx_http_request_t *r,
return NGX_ERROR;
}

// XXX set_header
#if 0
ngx_http_script_flush_no_cacheable_variables(r, tlcf->headers.flushes);
#endif

if (ngx_http_tnt_copy_headers(tp, &r->headers_in.headers, &map_items) ==
NGX_ERROR)
{
Expand Down
11 changes: 10 additions & 1 deletion src/ngx_http_tnt_handlers.h
Expand Up @@ -26,7 +26,7 @@
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Copyright (C) 2015-2016 Tarantool AUTHORS:
* Copyright (C) 2015-2017 Tarantool AUTHORS:
* please see AUTHORS file.
*/

Expand All @@ -47,6 +47,13 @@ typedef enum ngx_tnt_conf_states {
NGX_TNT_CONF_PASS_HEADERS_OUT = 32,
} ngx_tnt_conf_states_e;

typedef struct {
ngx_array_t *flushes;
ngx_array_t *lengths;
ngx_array_t *values;
ngx_hash_t hash;
} ngx_http_tnt_headers_t;

/** The structure hold the nginx location variables, e.g. loc_conf.
*/
typedef struct {
Expand Down Expand Up @@ -118,6 +125,8 @@ typedef struct {

ngx_array_t *headers_source;

ngx_http_tnt_headers_t headers;

} ngx_http_tnt_loc_conf_t;


Expand Down
9 changes: 7 additions & 2 deletions src/ngx_http_tnt_module.c
Expand Up @@ -26,7 +26,7 @@
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Copyright (C) 2015-2016 Tarantool AUTHORS:
* Copyright (C) 2015-2017 Tarantool AUTHORS:
* please see AUTHORS file.
*/

Expand All @@ -36,7 +36,6 @@
#include <ngx_http_tnt_version.h>
#include <ngx_http_tnt_handlers.h>


/** Filters
*/

Expand Down Expand Up @@ -111,6 +110,7 @@ static ngx_conf_bitmask_t ngx_http_tnt_methods[] = {
{ ngx_null_string, 0 }
};


static ngx_command_t ngx_http_tnt_commands[] = {

{ ngx_string("tnt_pass"),
Expand Down Expand Up @@ -473,6 +473,11 @@ ngx_http_tnt_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
(NGX_HTTP_POST
|NGX_HTTP_DELETE));

if (conf->headers_source == NULL) {
conf->headers = prev->headers;
conf->headers_source = prev->headers_source;
}

/** Experimental, see conf commands description [[
*/
ngx_conf_merge_bitmask_value(conf->pure_result,
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_tnt_version.h
Expand Up @@ -33,6 +33,6 @@
#ifndef NGX_HTTP_TNT_VERSION_H
#define NGX_HTTP_TNT_VERSION_H 1

#define NGX_HTTP_TNT_MODULE_VERSION_STRING "v2.3.2"
#define NGX_HTTP_TNT_MODULE_VERSION_STRING "v2.3.5"

#endif

0 comments on commit 494ce38

Please sign in to comment.