ext negotiation tolerate semicolon args
authorAndy Green <andy.green@linaro.org>
Wed, 30 Dec 2015 04:12:58 +0000 (12:12 +0800)
committerAndy Green <andy.green@linaro.org>
Wed, 30 Dec 2015 04:12:58 +0000 (12:12 +0800)
Signed-off-by: Andy Green <andy.green@linaro.org>
lib/client.c
lib/server-handshake.c

index 51e30f0..dbb2c36 100644 (file)
@@ -514,6 +514,7 @@ lws_client_interpret_server_handshake(struct lws *wsi)
        const struct lws_extension *ext;
        char ext_name[128];
        const char *c;
+       char ignore;
        int more = 1;
        void *v;
 #endif
@@ -648,15 +649,23 @@ check_extensions:
 
        c = (char *)context->serv_buf;
        n = 0;
+       ignore = 0;
        while (more) {
 
                if (*c && (*c != ',' && *c != ' ' && *c != '\t')) {
+                       if (*c == ';')
+                               ignore = 1;
+                       if (ignore) {
+                               c++;
+                               continue;
+                       }
                        ext_name[n] = *c++;
                        if (n < sizeof(ext_name) - 1)
                                n++;
                        continue;
                }
                ext_name[n] = '\0';
+               ignore = 0;
                if (!*c)
                        more = 0;
                else {
index 8c3e17c..c306baa 100644 (file)
@@ -33,6 +33,7 @@ lws_extension_server_handshake(struct lws *wsi, char **p)
        struct lws_context *context = wsi->context;
        int ext_count = 0;
        int more = 1;
+       char ignore;
 
        /*
         * Figure out which extensions the client has that we want to
@@ -56,15 +57,24 @@ lws_extension_server_handshake(struct lws *wsi, char **p)
        lwsl_parser("WSI_TOKEN_EXTENSIONS = '%s'\n", c);
        wsi->count_active_extensions = 0;
        n = 0;
+       ignore = 0;
        while (more) {
 
                if (*c && (*c != ',' && *c != ' ' && *c != '\t')) {
+                       if (ext_name[n] == ';')
+                               ignore = 1;
+                       if (ignore) {
+                               c++;
+                               continue;
+                       }
                        ext_name[n] = *c++;
                        if (n < sizeof(ext_name) - 1)
                                n++;
                        continue;
                }
                ext_name[n] = '\0';
+
+               ignore = 0;
                if (!*c)
                        more = 0;
                else {