From 5b4caddd98da4f1b16bfc54afcaac33165184e30 Mon Sep 17 00:00:00 2001 From: duffn <3457341+duffn@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:29:40 -0700 Subject: [PATCH] Make tokenize parameter split clearer (#4) --- src/vmod_querymodifier.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/vmod_querymodifier.c b/src/vmod_querymodifier.c index 57a4fa0..1b585d0 100644 --- a/src/vmod_querymodifier.c +++ b/src/vmod_querymodifier.c @@ -47,7 +47,6 @@ static int tokenize_querystring(VRT_CTX, query_param_t **result, return -1; } - // Tokenize the query parameters into an array. for (param_str = strtok_r(query_str, "&", &save_ptr); param_str; param_str = strtok_r(NULL, "&", &save_ptr)) { @@ -57,10 +56,14 @@ static int tokenize_querystring(VRT_CTX, query_param_t **result, return -1; } - params_array[no_param].name = param_str; - params_array[no_param].value = strchr(param_str, '='); - if (params_array[no_param].value) { - *(params_array[no_param].value++) = '\0'; + char *eq = strchr(param_str, '='); + if (eq != NULL) { + *eq = '\0'; + params_array[no_param].name = param_str; + params_array[no_param].value = eq + 1; + } else { + params_array[no_param].name = param_str; + params_array[no_param].value = NULL; } no_param++; }