X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=surf.c;h=ce8fce85f900c313e5c803fc68e5448d5cf9e09d;hb=d4e31d9472ec2f4ec9e44ad56926ee4cfed157ee;hp=a229994cd3be5ad792170e7de32bfd42dfd38dde;hpb=117d4848338315d15e1ab93cd551889fc6964a2b;p=surf.git diff --git a/surf.c b/surf.c index a229994..ce8fce8 100644 --- a/surf.c +++ b/surf.c @@ -95,7 +95,7 @@ static SoupCache *diskcache = NULL; static void addaccelgroup(Client *c); static void beforerequest(WebKitWebView *w, WebKitWebFrame *f, WebKitWebResource *r, WebKitNetworkRequest *req, - WebKitNetworkResponse *resp, gpointer d); + WebKitNetworkResponse *resp, Client *c); static char *buildpath(const char *path); static gboolean buttonrelease(WebKitWebView *web, GdkEventButton *e, GList *gl); @@ -138,6 +138,8 @@ static void getpagestat(Client *c); static char *geturi(Client *c); static gchar *getstyle(const char *uri); +static void handleplumb(Client *c, WebKitWebView *w, const gchar *uri); + static gboolean initdownload(WebKitWebView *v, WebKitDownload *o, Client *c); static void inspector(Client *c, const Arg *arg); @@ -209,11 +211,21 @@ addaccelgroup(Client *c) { static void beforerequest(WebKitWebView *w, WebKitWebFrame *f, WebKitWebResource *r, WebKitNetworkRequest *req, WebKitNetworkResponse *resp, - gpointer d) { + Client *c) { const gchar *uri = webkit_network_request_get_uri(req); if(g_str_has_suffix(uri, "/favicon.ico")) webkit_network_request_set_uri(req, "about:blank"); + + if(!g_str_has_prefix(uri, "http://") \ + && !g_str_has_prefix(uri, "https://") \ + && !g_str_has_prefix(uri, "about:") \ + && !g_str_has_prefix(uri, "file://") \ + && !g_str_has_prefix(uri, "data:") \ + && !g_str_has_prefix(uri, "blob:") \ + && strlen(uri) > 0) { + handleplumb(c, w, uri); + } } static char * @@ -561,6 +573,15 @@ getstyle(const char *uri) { return g_strdup(""); } +static void +handleplumb(Client *c, WebKitWebView *w, const gchar *uri) { + Arg arg; + + webkit_web_view_stop_loading(w); + arg = (Arg)PLUMB((char *)uri); + spawn(c, &arg); +} + static gboolean initdownload(WebKitWebView *view, WebKitDownload *o, Client *c) { Arg arg; @@ -955,7 +976,7 @@ newclient(void) { static void newwindow(Client *c, const Arg *arg, gboolean noembed) { guint i = 0; - const char *cmd[16], *uri; + const char *cmd[18], *uri; const Arg a = { .v = (void *)cmd }; char tmp[64];