Explorar o código

preliminary patch for query string issue reported on the ML

Christian Grothoff %!s(int64=7) %!d(string=hai) anos
pai
achega
d640ad8212
Modificáronse 3 ficheiros con 14 adicións e 8 borrados
  1. 3 0
      ChangeLog
  2. 1 1
      src/include/microhttpd.h
  3. 10 7
      src/microhttpd/connection.c

+ 3 - 0
ChangeLog

@@ -1,3 +1,6 @@
+Thu Feb  7 16:16:12 CET 2019
+	Preliminary patch for the raw query string issue, to be tested. -CG
+
 Tue Jan  8 02:57:21 BRT 2019
 	Added minimal example for how to compress HTTP response. -SC
 

+ 1 - 1
src/include/microhttpd.h

@@ -126,7 +126,7 @@ typedef intptr_t ssize_t;
  * Current version of the library.
  * 0x01093001 = 1.9.30-1.
  */
-#define MHD_VERSION 0x00096203
+#define MHD_VERSION 0x00096204
 
 /**
  * MHD-internal return code for "YES".

+ 10 - 7
src/microhttpd/connection.c

@@ -2257,7 +2257,7 @@ parse_initial_message_line (struct MHD_Connection *connection,
         http_version--;
       if (http_version > uri)
         {
-          /* http_version points to string before HTTP version string */
+          /* http_version points to character before HTTP version string */
           http_version[0] = '\0';
           connection->version = http_version + 1;
           uri_len = http_version - uri;
@@ -2277,24 +2277,21 @@ parse_initial_message_line (struct MHD_Connection *connection,
           return MHD_NO;
         }
 
-      /* unescape URI before searching for arguments */
-      daemon->unescape_callback (daemon->unescape_callback_cls,
-                                 connection,
-                                 uri);
-      uri_len = strlen (uri); /* recalculate: may have changed! */
       args = memchr (uri,
                      '?',
                      uri_len);
     }
 
+  /* log callback before we modify URI *or* args */
   if (NULL != daemon->uri_log_callback)
     {
       connection->client_aware = true;
       connection->client_context
         = daemon->uri_log_callback (daemon->uri_log_callback_cls,
-  				    curi,
+  				    uri,
                                     connection);
     }
+  
   if (NULL != args)
     {
       args[0] = '\0';
@@ -2306,6 +2303,12 @@ parse_initial_message_line (struct MHD_Connection *connection,
 			    &connection_add_header,
 			    &unused_num_headers);
     }
+  
+  /* unescape URI *after* searching for arguments and log callback */
+  if (NULL != uri)
+    daemon->unescape_callback (daemon->unescape_callback_cls,
+			       connection,
+			       uri);
   connection->url = curi;
   return MHD_YES;
 }