summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2012-02-19 21:32:24 +0100
committerportix <portix@gmx.net>2012-02-19 21:32:24 +0100
commit005c0ef9a819644684a64fd891b12642059303bf (patch)
treef7737bc702231e65a7402899a9de8597923385d6 /src
parent423df957879b2e83ff042bf9f837758550821c2c (diff)
downloaddwb-005c0ef9a819644684a64fd891b12642059303bf.zip
Fixing segfault when startpage is not set; fixing glib errors if documentviewer and fonts are not set
Diffstat (limited to 'src')
-rw-r--r--src/adblock.c18
-rw-r--r--src/dwb.c14
-rw-r--r--src/soup.c6
-rw-r--r--src/util.c2
-rw-r--r--src/view.c16
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;
}
diff --git a/src/dwb.c b/src/dwb.c
index e834a60b..3c69ff4c 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -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();
diff --git a/src/soup.c b/src/soup.c
index ab95cd94..e3a7b55b 100644
--- a/src/soup.c
+++ b/src/soup.c
@@ -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"))
diff --git a/src/util.c b/src/util.c
index 766187bd..f7808bb1 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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 {
diff --git a/src/view.c b/src/view.c
index 667d6e0c..72e7aae2 100644
--- a/src/view.c
+++ b/src/view.c
@@ -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);