Skip to content

Commit

Permalink
Make tokenize parameter split clearer (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
duffn authored Dec 17, 2024
1 parent 981d427 commit 5b4cadd
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/vmod_querymodifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {

Expand All @@ -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++;
}
Expand Down

0 comments on commit 5b4cadd

Please sign in to comment.