tsetcert: check uri before adding a certificate - surf - customized build of surf, the suckless webkit browser
 (HTM) git clone git://src.adamsgaard.dk/surf
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit edddfbc14ac3a4413f38171e8fd7767ae56e27bf
 (DIR) parent 21d81a71cc55ea52c836c49eca351940fefb1287
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Sat, 29 Apr 2017 22:16:03 +0200
       
       setcert: check uri before adding a certificate
       
       Also directly check for https scheme, we won't need a certificate for
       others.
       
       Diffstat:
         M surf.c                              |      12 +++++++-----
       
       1 file changed, 7 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git a/surf.c b/surf.c
       t@@ -792,14 +792,16 @@ setcert(Client *c, const char *uri)
                        return;
                }
        
       -        uri = strstr(uri, "://") + sizeof("://") - 1;
       -        host = strndup(uri, strstr(uri, "/") - uri);
       +        if ((uri = strstr(uri, "https://"))) {
       +                uri += sizeof("https://") - 1;
       +                host = g_strndup(uri, strchr(uri, '/') - uri);
       +                webkit_web_context_allow_tls_certificate_for_host(
       +                    webkit_web_view_get_context(c->view), cert, host);
       +                g_free(host);
       +        }
        
       -        webkit_web_context_allow_tls_certificate_for_host(
       -            webkit_web_view_get_context(c->view), cert, host);
                g_object_unref(cert);
        
       -        free(host);
        }
        
        const char *