diff options
-rw-r--r-- | src/adblock.c | 18 | ||||
-rw-r--r-- | src/dwb.c | 14 | ||||
-rw-r--r-- | src/soup.c | 6 | ||||
-rw-r--r-- | src/util.c | 2 | ||||
-rw-r--r-- | src/view.c | 16 |
5 files changed, 33 insertions, 23 deletions
diff --git a/src/adblock.c b/src/adblock.c index 606f09a1..c39100f6 100644 --- a/src/adblock.c +++ b/src/adblock.c @@ -541,7 +541,7 @@ adblock_resource_request_cb(WebKitWebView *wv, WebKitWebFrame *frame, const char *firstdomain = domain_get_base_for_host(firsthost); if (firstdomain == NULL) return; - gboolean thirdparty = strcmp(domain, firstdomain); + gboolean thirdparty = g_strcmp0(domain, firstdomain); if (!adblock_match(_simple_exceptions, uri, host, domain, firsthost, firstdomain, attribute, thirdparty)) { if (adblock_match(_simple_rules, uri, host, domain, firsthost, firstdomain, attribute, thirdparty)) { @@ -717,27 +717,27 @@ adblock_rule_parse(char *filterlist) { inverse = AB_INVERSE; o++; } - if (!strcmp(o, "script")) + if (!g_strcmp0(o, "script")) attributes |= (AA_SCRIPT << inverse); - else if (!strcmp(o, "image")) + else if (!g_strcmp0(o, "image")) attributes |= (AA_IMAGE << inverse); - else if (!strcmp(o, "stylesheet")) + else if (!g_strcmp0(o, "stylesheet")) attributes |= (AA_STYLESHEET << inverse); - else if (!strcmp(o, "object")) { + else if (!g_strcmp0(o, "object")) { attributes |= (AA_OBJECT << inverse); } - else if (!strcmp(o, "subdocument")) { + else if (!g_strcmp0(o, "subdocument")) { attributes |= inverse ? AA_DOCUMENT : AA_SUBDOCUMENT; } - else if (!strcmp(o, "document")) { + else if (!g_strcmp0(o, "document")) { if (exception) attributes |= inverse ? AA_DOCUMENT : AA_SUBDOCUMENT; else adblock_warn_ignored("Adblock option 'document' can only be applied to exception rules", pattern); } - else if (!strcmp(o, "match-case")) + else if (!g_strcmp0(o, "match-case")) option |= AO_MATCH_CASE; - else if (!strcmp(o, "third-party")) { + else if (!g_strcmp0(o, "third-party")) { if (inverse) { option |= AO_NOTHIRDPARTY; } @@ -3008,9 +3008,16 @@ dwb_init_style() { char *font = GET_CHAR("font"); - dwb.font.fd_active = pango_font_description_from_string(font); + if (font) + dwb.font.fd_active = pango_font_description_from_string(font); char *f; -#define SET_FONT(var, prop) f = GET_CHAR(prop); var = pango_font_description_from_string(f ? f : font) +#define SET_FONT(var, prop) do { \ + if ((f = GET_CHAR(prop)) != NULL) \ + var = pango_font_description_from_string(f); \ + else if (dwb.font.fd_active) \ + var = dwb.font.fd_active; \ + } while(0) + SET_FONT(dwb.font.fd_inactive, "font-inactive"); SET_FONT(dwb.font.fd_entry, "font-entry"); SET_FONT(dwb.font.fd_completion, "font-completion"); @@ -3458,7 +3465,8 @@ dwb_init(GSList *exe, char *restore) { g_free(path); } char *cache_model = GET_CHAR("cache-model"); - if (!g_ascii_strcasecmp(cache_model, "documentviewer")) + + if (cache_model != NULL && !g_ascii_strcasecmp(cache_model, "documentviewer")) webkit_set_cache_model(WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER); dwb_init_key_map(); @@ -188,12 +188,12 @@ DwbStatus dwb_soup_set_cookie_accept_policy(const char *policy) { SoupCookieJarAcceptPolicy apo = 37; DwbStatus ret = STATUS_OK; + if (policy == NULL || ! g_ascii_strcasecmp(policy, "always")) + apo = SOUP_COOKIE_JAR_ACCEPT_ALWAYS; if (! g_ascii_strcasecmp(policy, "nothirdparty")) apo = SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY; else if (! g_ascii_strcasecmp(policy, "never")) apo = SOUP_COOKIE_JAR_ACCEPT_NEVER; - else if (! g_ascii_strcasecmp(policy, "always")) - apo = SOUP_COOKIE_JAR_ACCEPT_ALWAYS; if (apo == 37) { dwb_set_error_message(dwb.state.fview, "Invalid value for cookies-accept-policy: %d, using 0", policy); @@ -207,6 +207,8 @@ dwb_soup_set_cookie_accept_policy(const char *policy) { /* dwb_soup_get_cookie_store_policy(const char *policy) {{{*/ CookieStorePolicy dwb_soup_get_cookie_store_policy(const char *policy) { + if (policy == NULL) + return COOKIE_STORE_SESSION; if (! g_ascii_strcasecmp(policy, "persistent")) return COOKIE_STORE_PERSISTENT; else if (! g_ascii_strcasecmp(policy, "never")) @@ -149,7 +149,7 @@ util_char_to_arg(char *value, DwbType type) { } } if (type == BOOLEAN) { - if(!g_ascii_strcasecmp(value, "false") || !g_strcmp0(value, "0")) { + if(value == NULL || !g_ascii_strcasecmp(value, "false") || !g_strcmp0(value, "0")) { ret->b = false; } else { @@ -402,12 +402,12 @@ view_navigation_policy_cb(WebKitWebView *web, WebKitWebFrame *frame, WebKitNetwo /* mailto, ftp */ char *scheme = g_uri_parse_scheme(uri); if (scheme) { - if (!strcmp(scheme, "mailto")) { + if (!g_strcmp0(scheme, "mailto")) { dwb_spawn(gl, "mail-client", uri); webkit_web_policy_decision_ignore(policy); ret = true; } - else if (!strcmp(scheme, "ftp")) { + else if (!g_strcmp0(scheme, "ftp")) { dwb_spawn(gl, "ftp-client", uri); webkit_web_policy_decision_ignore(policy); ret = true; @@ -501,7 +501,7 @@ view_popup_activate_cb(GtkMenuItem *menu, GList *gl) { if (a == NULL) return; name = gtk_action_get_name(a); - if (!strcmp(name, "context-menu-action-3")) { /* copy link location */ + if (!g_strcmp0(name, "context-menu-action-3")) { /* copy link location */ GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); gtk_clipboard_set_text(clipboard, VIEW(gl)->status->hover_uri, -1); } @@ -563,15 +563,15 @@ view_load_status_cb(WebKitWebView *web, GParamSpec *pspec, GList *gl) { if (VIEW(gl)->status->scripts & SCRIPTS_BLOCKED && (((host = dwb_get_host(web)) && (dwb_get_allowed(dwb.files.scripts_allow, host) || dwb_get_allowed(dwb.files.scripts_allow, uri) - || g_list_find_custom(dwb.fc.tmp_scripts, host, (GCompareFunc)strcmp) || g_list_find_custom(dwb.fc.tmp_scripts, uri, (GCompareFunc)strcmp))) - || !strcmp(uri, "dwb://") || !strcmp(uri, "Error"))) { + || g_list_find_custom(dwb.fc.tmp_scripts, host, (GCompareFunc)g_strcmp0) || g_list_find_custom(dwb.fc.tmp_scripts, uri, (GCompareFunc)g_strcmp0))) + || !g_strcmp0(uri, "dwb://") || !g_strcmp0(uri, "Error"))) { g_object_set(webkit_web_view_get_settings(web), "enable-scripts", true, NULL); v->status->scripts |= SCRIPTS_ALLOWED_TEMPORARY; } if (v->plugins->status & PLUGIN_STATUS_ENABLED && ( (host != NULL || (host = dwb_get_host(web))) && (dwb_get_allowed(dwb.files.plugins_allow, host) || dwb_get_allowed(dwb.files.plugins_allow, uri) - || g_list_find_custom(dwb.fc.tmp_plugins, host, (GCompareFunc)strcmp) || g_list_find_custom(dwb.fc.tmp_plugins, uri, (GCompareFunc)strcmp) ) + || g_list_find_custom(dwb.fc.tmp_plugins, host, (GCompareFunc)g_strcmp0) || g_list_find_custom(dwb.fc.tmp_plugins, uri, (GCompareFunc)g_strcmp0) ) )) { plugins_disconnect(gl); } @@ -581,7 +581,7 @@ view_load_status_cb(WebKitWebView *web, GParamSpec *pspec, GList *gl) { dwb_update_status(gl); /* TODO sqlite */ if (!dwb.misc.private_browsing - && strcmp(uri, "about:blank") + && g_strcmp0(uri, "about:blank") && !g_str_has_prefix(uri, "dwb://") && (dwb_prepend_navigation(gl, &dwb.fc.history) == STATUS_OK) && dwb.misc.synctimer <= 0) { @@ -985,7 +985,7 @@ view_add(const char *uri, gboolean background) { if (uri != NULL) { dwb_load_uri(ret, uri); } - else if (strcmp("about:blank", dwb.misc.startpage)) { + else if (g_strcmp0("about:blank", dwb.misc.startpage)) { char *page = g_strdup(dwb.misc.startpage); dwb_load_uri(ret, page); g_free(page); |