Here you are a small patch for eve to make it always load an http://
link if no protocol is specified.

Bye
From bedf0cc1195c9f850c4c9dbefab5185397713744 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20(Trevi=C3=B1o)?= <m...@3v1n0.net>
Date: Tue, 16 Nov 2010 17:02:33 +0100
Subject: [PATCH] eve: sanitize input URIs adding the default http protocol

This fix is now applied also to command line parameter and to
the homepage config saver
---
 src/bin/chrome.c  |   13 ++++++-------
 src/bin/main.c    |   39 +++++++++++++++++++++++++++++++++------
 src/bin/private.h |    2 ++
 3 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/src/bin/chrome.c b/src/bin/chrome.c
index ffa1196..588cbf7 100644
--- a/src/bin/chrome.c
+++ b/src/bin/chrome.c
@@ -2109,14 +2109,13 @@ on_action_load_page(void *data, Evas_Object *view, void *event_info __UNUSED__)
    Evas_Object *ewk_view = data;
 
    const char *entry_data = elm_scrolled_entry_entry_get(view);
+   char *uri;
 
-   char uri[2048];
-
-   snprintf(uri, 2048, "%s%s",
-            (strstr(entry_data, "://") ? "" : "http://";), entry_data);
-
-   ewk_view_uri_set(ewk_view, uri);
-   evas_object_focus_set(ewk_view, EINA_TRUE);
+   if ((uri = sanitize_uri((char *)entry_data))) {
+      ewk_view_uri_set(ewk_view, uri);
+      evas_object_focus_set(ewk_view, EINA_TRUE);
+      free(uri);
+   }
 }
 
 static void
diff --git a/src/bin/main.c b/src/bin/main.c
index dd66d9e..d1b6a25 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -379,11 +379,16 @@ _cb_dbus_open_url(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
 {
    DBusMessage *reply;
    Browser_Window *win = eina_list_data_get(app.windows);
-   char *new_url;
+   char *tmp_uri;
+   char *uri;
 
-   dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &new_url, DBUS_TYPE_INVALID);
-   tab_add(win, new_url, NULL);
-   ecore_x_window_focus(elm_win_xwindow_get(win->win));
+   dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &tmp_uri, DBUS_TYPE_INVALID);
+
+   if ((uri = sanitize_uri(tmp_uri))) {
+      tab_add(win, uri, NULL);
+      ecore_x_window_focus(elm_win_xwindow_get(win->win));
+      free(uri);
+   }
 
    return dbus_message_new_method_return(msg);
 }
@@ -572,13 +577,29 @@ session_restore(void)
    return !!n_tabs;
 }
 
+char *
+sanitize_uri(char *uri) {
+   char *fixed_uri;
+
+   if (!uri || !strlen(uri))
+      return NULL;
+
+   if (asprintf(&fixed_uri, "%s%s",
+            (strstr(uri, "://") ? "" : "http://";), uri) > 0)
+     {
+      return fixed_uri;
+     }
+
+   return NULL;
+}
+
 EAPI int
 elm_main(int argc, char **argv)
 {
    int r = 0, args;
    const char *home;
    const char *url;
-   char path[PATH_MAX], *basename;
+   char path[PATH_MAX], *basename, *tmp_uri;
    Eina_Bool quit_option = EINA_FALSE;
    Eina_Bool disable_plugins = 0xff;
    Eina_Bool disable_mouse_cursor = 0xff;
@@ -804,8 +825,12 @@ elm_main(int argc, char **argv)
           }
      }
 
+   tmp_uri = NULL;
    if (args < argc)
-      url = argv[args];
+     {
+      tmp_uri = sanitize_uri(argv[args]);
+      url = tmp_uri;
+     }
    else
       url = config_home_page_get(config);
 
@@ -831,6 +856,8 @@ elm_main(int argc, char **argv)
         goto end;
      }
 
+   if (tmp_uri) free(tmp_uri);
+
    elm_run();
 end:
    config_save(config, NULL);
diff --git a/src/bin/private.h b/src/bin/private.h
index e826ef3..09f08bd 100644
--- a/src/bin/private.h
+++ b/src/bin/private.h
@@ -103,4 +103,6 @@ Eina_Bool             tab_close_nth(Browser_Window *win, int n);
 Eina_Bool             tab_close_view(Browser_Window *win, Evas_Object *view);
 Eina_Bool             tab_close_chrome(Browser_Window *win, Evas_Object *chrome);
 
+char *                sanitize_uri(char *uri);
+
 #endif
-- 
1.7.1

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to