aboutsummaryrefslogtreecommitdiffhomepage
path: root/uzbl.c
diff options
context:
space:
mode:
authorGravatar dusanx <ef_dva@yahoo.com>2009-04-28 01:00:44 +0200
committerGravatar dusanx <ef_dva@yahoo.com>2009-04-28 01:00:44 +0200
commit5d0a67929ce39365c9b7a46250c88af511e43c2f (patch)
tree106131a5f91468a301f77698916cb7a3cabc291d /uzbl.c
parent8be6f1a68f17d9cb9b64da4b09cc833c167f4038 (diff)
Proper uri handling, fixed segfault
Diffstat (limited to 'uzbl.c')
-rw-r--r--uzbl.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/uzbl.c b/uzbl.c
index 1b4cd8b..309ff6a 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -108,7 +108,7 @@ static void
update_title (GtkWindow* window);
static void
-load_uri ( WebKitWebView * web_view, gchar * uri);
+load_uri ( WebKitWebView * web_view, const gchar * uri);
static gboolean
run_command(const char *command, const char *args);
@@ -217,18 +217,6 @@ static Command commands[] =
/* -- CORE FUNCTIONS -- */
-static gchar*
-uricheck (gchar* uri) {
- if (g_strrstr (uri,"://") == NULL) {
- GString* newuri = g_string_new (uri);
- free(uri);
- g_string_prepend (newuri, "http://");
- uri = g_string_free (newuri, FALSE);
- }
- return (uri);
-}
-
-
static bool
file_exists (const char * filename) {
FILE *file = fopen (filename, "r");
@@ -240,8 +228,14 @@ file_exists (const char * filename) {
}
static void
-load_uri ( WebKitWebView * web_view, gchar * uri) {
- webkit_web_view_load_uri (web_view, uricheck(uri));
+load_uri (WebKitWebView * web_view, const gchar * uri) {
+ if (uri != NULL) {
+ GString* newuri = g_string_new (uri);
+ if (g_strrstr (uri, "://") == NULL)
+ g_string_prepend (newuri, "http://");
+ webkit_web_view_load_uri (web_view, newuri->str);
+ g_string_free (newuri, TRUE);
+ }
}
@@ -280,7 +274,7 @@ parse_command(const char *cmd) {
if (c->func_2_params != NULL) {
if (command_param != NULL) {
printf ("command executing: \"%s %s\"\n", command_name, command_param);
- c->func_2_params (web_view, uricheck(command_param));
+ c->func_2_params (web_view, command_param);
} else {
if (c->func_1_param != NULL) {
printf ("command executing: \"%s\"\n", command_name);
@@ -625,7 +619,7 @@ main (int argc, char* argv[]) {
main_window = create_window ();
gtk_container_add (GTK_CONTAINER (main_window), vbox);
- webkit_web_view_load_uri (web_view, uricheck(uri));
+ load_uri (web_view, uri);
gtk_widget_grab_focus (GTK_WIDGET (web_view));
gtk_widget_show_all (main_window);