diff --git a/surf.c b/surf.c index 2b54e3c..80b2c27 100644 --- a/surf.c +++ b/surf.c @@ -1687,6 +1687,24 @@ decideresource(WebKitPolicyDecision *d, Client *c) return; } + if (g_str_has_prefix(uri, "file://")) { + /* chop off the query/fragment part (RFC 3986) if any */ + const gchar *uri_end = g_strstr_len(uri, -1, "?"); + + if (!uri_end) + uri_end = g_strstr_len(uri, -1, "#"); + + if (!uri_end) + uri_end = uri + strlen(uri); + + if (!strncmp(uri_end - 5, ".html", 5) || + !strncmp(uri_end - 4, ".htm", 4)) { + /* if this is an html file, open it locally */ + webkit_policy_decision_use(d); + return; + } + } + if (!g_str_has_prefix(uri, "http://") && !g_str_has_prefix(uri, "https://") && !g_str_has_prefix(uri, "about:")