don't add empty query to rq->reqpb

Wed, 31 May 2023 12:49:44 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 31 May 2023 12:49:44 +0200
changeset 495
855a915472ff
parent 494
f7f624cfe80a
child 496
d511c13ba68d

don't add empty query to rq->reqpb

src/server/daemon/httprequest.c file | annotate | diff | comparison | revisions
--- a/src/server/daemon/httprequest.c	Wed May 31 12:43:30 2023 +0200
+++ b/src/server/daemon/httprequest.c	Wed May 31 12:49:44 2023 +0200
@@ -252,11 +252,12 @@
         return 1;
     }
     
-    cxmutstr query;
-    query.length = 0;
-    
     for(int i=0;i<request->uri.length;i++) {
         if(request->uri.ptr[i] == '?') {
+            cxmutstr query;
+            query.ptr = NULL;
+            query.length = 0;
+            
             /* split uri in path and query */
             if(absPath.length > i + 2) {
                 query.length = absPath.length - i - 1;
@@ -265,11 +266,13 @@
             absPath.length = i;
 
             // Pass any query as 'query' in reqpb
-            pblock_kvinsert(
+            if(query.length > 0) {
+                pblock_kvinsert(
                     pb_key_query,
                     query.ptr,
                     query.length,
                     rq->rq.reqpb);
+            }
 
             break;
         }

mercurial