[FIX] Decode pathPart instead of substr itself.

This commit is contained in:
lda 2023-11-30 19:17:44 +01:00
parent bca94c0309
commit fb8ec5f3ae
Signed by: lda
GPG key ID: 6898757653ABE3E6

View file

@ -229,12 +229,15 @@ HttpRouterRoute(HttpRouter * router, char *path, void *args, void **ret)
regmatch_t pmatch[REG_MAX_SUB]; regmatch_t pmatch[REG_MAX_SUB];
pathPart = HttpUrlDecode(pathPart);
i = 0; i = 0;
while (HashMapIterateReentrant(node->children, &key, (void **) &val, &i)) while (HashMapIterateReentrant(node->children, &key, (void **) &val, &i))
{ {
if (regexec(&val->regex, pathPart, REG_MAX_SUB, pmatch, 0) == 0) if (regexec(&val->regex, pathPart, REG_MAX_SUB, pmatch, 0) == 0)
{ {
Free(pathPart);
break; break;
} }
@ -244,6 +247,7 @@ HttpRouterRoute(HttpRouter * router, char *path, void *args, void **ret)
if (!val) if (!val)
{ {
exec = NULL; exec = NULL;
Free(pathPart);
break; break;
} }
@ -264,13 +268,14 @@ HttpRouterRoute(HttpRouter * router, char *path, void *args, void **ret)
substr = StrSubstr(pathPart, cpmatch.rm_so, cpmatch.rm_eo); substr = StrSubstr(pathPart, cpmatch.rm_so, cpmatch.rm_eo);
if (pmatch[i].rm_so == -1) if (pmatch[i].rm_so == -1)
{ {
Free(pathPart);
break; break;
} }
ArrayAdd(matches, HttpUrlDecode(substr)); ArrayAdd(matches, substr);
Free(substr);
} }
} }
Free(pathPart);
} }
Free(path); Free(path);
} }