diff options
author | portix <none@none> | 2013-01-07 23:39:51 +0100 |
---|---|---|
committer | portix <none@none> | 2013-01-07 23:39:51 +0100 |
commit | a086ab66867e10bc7dfc8361d4ad174b9fa76b22 (patch) | |
tree | 73e42bafbe1f6bda6c657aabea123888b4aa1048 /src | |
parent | 7932a6209201d03609e125ccc5280ce4dc12d2d3 (diff) | |
download | dwb-a086ab66867e10bc7dfc8361d4ad174b9fa76b22.zip |
Expand ~ in user-stylesheet-uri; don't throw exceptions when an argument is missing
Diffstat (limited to 'src')
-rw-r--r-- | src/config.h | 2 | ||||
-rw-r--r-- | src/dwb.c | 16 | ||||
-rw-r--r-- | src/scripts.c | 26 | ||||
-rw-r--r-- | src/util.c | 1 |
4 files changed, 23 insertions, 22 deletions
diff --git a/src/config.h b/src/config.h index d902c864..ec726f91 100644 --- a/src/config.h +++ b/src/config.h @@ -941,7 +941,7 @@ static WebSettings DWB_SETTINGS[] = { { { "user-agent", "The user agent string", }, SETTING_PER_VIEW, CHAR, { .p = NULL }, (S_Func) dwb_set_user_agent, { 0 }, }, { { "user-stylesheet-uri", "The uri of a stylsheet applied to every page", }, - SETTING_BUILTIN, CHAR, { .p = NULL }, (S_Func) dwb_webkit_setting, { 0 }, }, + SETTING_BUILTIN, CHAR, { .p = NULL }, (S_Func) dwb_set_user_stylesheet, { 0 }, }, { { "zoom-step", "The zoom step", }, SETTING_BUILTIN, DOUBLE, { .d = 0.1 }, (S_Func) dwb_webkit_setting, { 0 }, }, { { "custom-encoding", "The custom encoding of the tab", }, @@ -55,6 +55,7 @@ static DwbStatus dwb_webview_property(GList *, WebSettings *); static DwbStatus dwb_set_background_tab(GList *, WebSettings *); static DwbStatus dwb_set_scripts(GList *, WebSettings *); static DwbStatus dwb_set_user_agent(GList *, WebSettings *); +static DwbStatus dwb_set_user_stylesheet(GList *, WebSettings *); static DwbStatus dwb_set_startpage(GList *, WebSettings *); static DwbStatus dwb_set_message_delay(GList *, WebSettings *); static DwbStatus dwb_set_history_length(GList *, WebSettings *); @@ -488,6 +489,21 @@ dwb_set_user_agent(GList *gl, WebSettings *s) return STATUS_OK; }/*}}}*/ +static DwbStatus +dwb_set_user_stylesheet(GList *gl, WebSettings *s) +{ + char *ua = s->arg_local.p; + char *new = NULL; + if (ua) + s->arg_local.p = new = util_string_replace(ua, "~", g_getenv("HOME")); + + dwb_webkit_setting(gl, s); + if (ua) + s->arg_local.p = ua; + g_hash_table_insert(dwb.settings, g_strdup("user-stylesheet-uri"), s); + g_free(new); + return STATUS_OK; +}/*}}}*/ /* dwb_webkit_setting(GList *gl WebSettings *s) {{{*/ static DwbStatus diff --git a/src/scripts.c b/src/scripts.c index b85c6218..9959ec72 100644 --- a/src/scripts.c +++ b/src/scripts.c @@ -893,10 +893,8 @@ global_checksum(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, JSValueRef ret; if (argc < 1) - { - js_make_exception(ctx, exc, EXCEPTION("checksum: missing argument.")); return NIL; - } + original = (guchar*)js_value_to_char(ctx, argv[0], -1, exc); if (original == NULL) return NIL; @@ -945,10 +943,8 @@ static JSValueRef global_unbind(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exc) { if (argc < 1) - { - js_make_exception(ctx, exc, EXCEPTION("unbind: missing argument.")); return JSValueMakeBoolean(ctx, false); - } + GList *l = NULL; KeyMap *m; if (JSValueIsString(ctx, argv[0])) @@ -986,10 +982,8 @@ global_bind(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size guint option = CP_DONT_SAVE | CP_SCRIPT; if (argc < 2) - { - js_make_exception(ctx, exc, EXCEPTION("bind: missing argument.")); return JSValueMakeBoolean(ctx, false); - } + keystr = js_value_to_char(ctx, argv[0], JS_STRING_MAX, exc); JSObjectRef func = js_value_to_function(ctx, argv[1], exc); @@ -1042,10 +1036,8 @@ global_execute(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, s { DwbStatus status = STATUS_ERROR; if (argc < 1) - { - js_make_exception(ctx, exc, EXCEPTION("execute: missing argument.")); return JSValueMakeBoolean(ctx, false); - } + char *command = js_value_to_char(ctx, argv[0], -1, exc); if (command != NULL) { @@ -1076,10 +1068,7 @@ global_include(JSContextRef ctx, JSObjectRef f, JSObjectRef thisObject, size_t a char *path = NULL, *content = NULL; if (argc < 1) - { - js_make_exception(ctx, exc, EXCEPTION("include: missing argument.")); return NIL; - } if (argc > 1 && JSValueIsBoolean(ctx, argv[1])) global = JSValueToBoolean(ctx, argv[1]); @@ -1179,10 +1168,7 @@ global_send_request(JSContextRef ctx, JSObjectRef f, JSObjectRef thisObject, siz SoupMessage *msg; JSObjectRef function; if (argc < 2) - { - js_make_exception(ctx, exc, EXCEPTION("sendRequest: missing argument.")); return JSValueMakeNumber(ctx, -1); - } uri = js_value_to_char(ctx, argv[0], -1, exc); if (uri == NULL) @@ -1222,10 +1208,8 @@ global_send_request_sync(JSContextRef ctx, JSObjectRef f, JSObjectRef thisObject JSValueRef js_value; if (argc < 1) - { - js_make_exception(ctx, exc, EXCEPTION("sendRequestSync: missing argument.")); return NIL; - } + uri = js_value_to_char(ctx, argv[0], -1, exc); if (uri == NULL) return NIL; @@ -342,6 +342,7 @@ util_expand_home(char *buffer, const char *filename, size_t length) { strncpy(buffer, filename, length); return buffer; } + char * util_normalize_filename(char *buffer, const char *filename, size_t length) { char *tmp = buffer; |