commit 083a338

grunfink  ·  2026-02-03 06:15:22 +0000 UTC
parent 8dd5101
Tweaked check_signature() for GET variables.

Instead of unconditionally stripping ? variables when retrieving the keyId,
try first calling actor_request() directly, and only strip them and retry
if it fails.
1 files changed,  +13, -5
M http.c
M http.c
+13, -5
 1@@ -182,14 +182,22 @@ int check_signature(const xs_dict *req, xs_str **err)
 2     if ((p = strchr(keyId, '#')) != NULL)
 3         *p = '\0';
 4 
 5-    /* also strip cgi variables */
 6-    if ((p = strchr(keyId, '?')) != NULL)
 7-        *p = '\0';
 8-
 9     xs *actor = NULL;
10     int status;
11 
12-    if (!valid_status((status = actor_request(NULL, keyId, &actor)))) {
13+    /* does it have ? variables? */
14+    if ((p = strchr(keyId, '?')) != NULL) {
15+        /* try first with them */
16+        if (!valid_status((status = actor_request(NULL, keyId, &actor)))) {
17+            *p = '\0';
18+            /* retry stripping them */
19+            status = actor_request(NULL, keyId, &actor);
20+        }
21+    }
22+    else
23+        status = actor_request(NULL, keyId, &actor);
24+
25+    if (!valid_status(status)) {
26         *err = xs_fmt("actor request error %s %d", keyId, status);
27         return 0;
28     }