From fb8ec5f3ae99a7b50bf1579f063729ea032a8852 Mon Sep 17 00:00:00 2001 From: lda Date: Thu, 30 Nov 2023 19:17:44 +0100 Subject: [PATCH] [FIX] Decode pathPart instead of substr itself. --- src/HttpRouter.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/HttpRouter.c b/src/HttpRouter.c index 809674f..ef16399 100644 --- a/src/HttpRouter.c +++ b/src/HttpRouter.c @@ -229,12 +229,15 @@ HttpRouterRoute(HttpRouter * router, char *path, void *args, void **ret) regmatch_t pmatch[REG_MAX_SUB]; + pathPart = HttpUrlDecode(pathPart); + i = 0; while (HashMapIterateReentrant(node->children, &key, (void **) &val, &i)) { if (regexec(&val->regex, pathPart, REG_MAX_SUB, pmatch, 0) == 0) { + Free(pathPart); break; } @@ -244,6 +247,7 @@ HttpRouterRoute(HttpRouter * router, char *path, void *args, void **ret) if (!val) { exec = NULL; + Free(pathPart); break; } @@ -264,13 +268,14 @@ HttpRouterRoute(HttpRouter * router, char *path, void *args, void **ret) substr = StrSubstr(pathPart, cpmatch.rm_so, cpmatch.rm_eo); if (pmatch[i].rm_so == -1) { + Free(pathPart); break; } - ArrayAdd(matches, HttpUrlDecode(substr)); - Free(substr); + ArrayAdd(matches, substr); } } + Free(pathPart); } Free(path); }