Przeglądaj źródła

Merge pull request #369 from feneuilflo/master

bugfix for #367 - ignore leading whitespaces when matching websocket protocols
bel2125 8 lat temu
rodzic
commit
6d22951c61
1 zmienionych plików z 4 dodań i 2 usunięć
  1. 4 2
      src/civetweb.c

+ 4 - 2
src/civetweb.c

@@ -9836,7 +9836,8 @@ handle_websocket_request(struct mg_connection *conn,
 				sep = strchr(protocol, ',');
 				curSubProtocol = protocol;
 				len = sep ? (unsigned long)(sep - protocol) : strlen(protocol);
-				protocol = sep ? sep + 1 : NULL;
+				while(sep && isspace(*++sep)); // ignore leading whitespaces
+				protocol = sep;
 
 
 				for (idx = 0; idx < subprotocols->nb_subprotocols; idx++) {
@@ -9871,7 +9872,8 @@ handle_websocket_request(struct mg_connection *conn,
 				 * and use it to select one protocol among those the client has
 				 * offered.
 				 */
-				conn->request_info.acceptedWebSocketSubprotocol = (sep + 1);
+				while(isspace(*++sep)); // ignore leading whitespaces
+				conn->request_info.acceptedWebSocketSubprotocol = sep;
 			}
 		}