diff options
author | Paweł Zuzelski <pawelz@pld-linux.org> | 2010-01-25 12:55:44 +0100 |
---|---|---|
committer | Paweł Zuzelski <pawelz@pld-linux.org> | 2010-01-25 12:55:44 +0100 |
commit | 238b199ee595df2f6e6db299d8de4de9193e4b10 (patch) | |
tree | 78440019569d9ab8aaec307285613c23015c7b64 /src | |
parent | c5621d312b1ce79a6242a4aa4a9cb4b3181c6d33 (diff) |
handle empty/unset authentication_handler
treat empty string as unset variable.
don't try to read stdout, if there is no stdout (this fixes segv reported by
Dieter).
Diffstat (limited to 'src')
-rw-r--r-- | src/callbacks.c | 6 | ||||
-rw-r--r-- | src/uzbl-core.c | 30 |
2 files changed, 21 insertions, 15 deletions
diff --git a/src/callbacks.c b/src/callbacks.c index 80846e3..3aa70fb 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -28,11 +28,11 @@ set_proxy_url() { void set_authentication_handler() { - if (uzbl.behave.authentication_handler) - soup_session_remove_feature_by_type + if (uzbl.behave.authentication_handler == NULL || *uzbl.behave.authentication_handler == NULL) + soup_session_add_feature_by_type (uzbl.net.soup_session, (GType) WEBKIT_TYPE_SOUP_AUTH_DIALOG); else - soup_session_add_feature_by_type + soup_session_remove_feature_by_type (uzbl.net.soup_session, (GType) WEBKIT_TYPE_SOUP_AUTH_DIALOG); return; } diff --git a/src/uzbl-core.c b/src/uzbl-core.c index 1558882..3a11e2a 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -2326,9 +2326,7 @@ void handle_authentication (SoupSession *session, SoupMessage *msg, SoupAuth *au (void) user_data; if(uzbl.behave.authentication_handler) { - char *username, *password; gchar *info, *host, *realm; - int number_of_endls=0; gchar *p; soup_session_pause_message(session, msg); @@ -2347,20 +2345,28 @@ void handle_authentication (SoupSession *session, SoupMessage *msg, SoupAuth *au run_handler(uzbl.behave.authentication_handler, s->str); - username = uzbl.comm.sync_stdout; + if (uzbl.comm.sync_stdout && strcmp (uzbl.comm.sync_stdout, "") != 0) { + char *username, *password; + int number_of_endls=0; - for (p = uzbl.comm.sync_stdout; *p; p++) { - if (*p == '\n') { - *p = '\0'; - if (++number_of_endls == 1) - password = p + 1; + username = uzbl.comm.sync_stdout; + + for (p = uzbl.comm.sync_stdout; *p; p++) { + if (*p == '\n') { + *p = '\0'; + if (++number_of_endls == 1) + password = p + 1; + } } + + /* If stdout was correct (contains exactly two lines of text) do + * authenticate. */ + if (number_of_endls == 2) + soup_auth_authenticate(auth, username, password); } - /* If stdout was correct (contains exactly two lines of text) do - * authenticate. */ - if (number_of_endls == 2) - soup_auth_authenticate(auth, username, password); + if (uzbl.comm.sync_stdout) + uzbl.comm.sync_stdout = strfree(uzbl.comm.sync_stdout); soup_session_unpause_message(session, msg); |