Hello, here you are two patches for eve sanitize's URI function:
* Sanitize also the homepage value set by user
* always check if the requested URI refers to a file; in this
case, add the file:// protocol/schema instead to the http://
one.
* Doesn't allow to use schemas with more than 15 chars (this seems
the max length of the IANA registered schemas).
Bye
From c803b3169dbec363e70d958d5c394ed59c8cc372 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20(Trevi=C3=B1o)?= <m...@3v1n0.net>
Date: Mon, 29 Nov 2010 14:59:20 +0100
Subject: [PATCH 1/2] eve: uri_sanitize also the input homepage
Plus some style fixes and set the input as const char
---
src/bin/chrome.c | 2 +-
src/bin/eve_state.c | 8 ++++++--
src/bin/main.c | 2 +-
src/bin/private.h | 2 +-
4 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/bin/chrome.c b/src/bin/chrome.c
index b0e61cc..f7e0c9d 100644
--- a/src/bin/chrome.c
+++ b/src/bin/chrome.c
@@ -2112,7 +2112,7 @@ on_action_load_page(void *data, Evas_Object *view, void *event_info __UNUSED__)
const char *entry_data = elm_scrolled_entry_entry_get(view);
char *uri;
- if ((uri = uri_sanitize((char *)entry_data)))
+ if ((uri = uri_sanitize(entry_data)))
{
ewk_view_uri_set(ewk_view, uri);
evas_object_focus_set(ewk_view, EINA_TRUE);
diff --git a/src/bin/eve_state.c b/src/bin/eve_state.c
index 29c17ec..65ac813 100644
--- a/src/bin/eve_state.c
+++ b/src/bin/eve_state.c
@@ -277,9 +277,13 @@ inline void
config_home_page_set(Config *config, const char *home_page)
{
EINA_SAFETY_ON_NULL_RETURN(config);
- eina_stringshare_replace(&(config->home_page), home_page);
+ char *tmp_uri;
+ if ((tmp_uri = uri_sanitize(home_page))) {
+ eina_stringshare_replace(&(config->home_page), tmp_uri);
+ free(tmp_uri);
+ }
}
-
+
inline const char *
config_proxy_get(const Config *config)
{
diff --git a/src/bin/main.c b/src/bin/main.c
index 8a7cf29..03dbb38 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -579,7 +579,7 @@ session_restore(void)
}
char *
-uri_sanitize(char *uri) {
+uri_sanitize(const char *uri) {
char *fixed_uri;
if (!uri || !*uri) return NULL;
diff --git a/src/bin/private.h b/src/bin/private.h
index ae78fb0..f11f09d 100644
--- a/src/bin/private.h
+++ b/src/bin/private.h
@@ -103,6 +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 * uri_sanitize(char *uri);
+char * uri_sanitize(const char *uri);
#endif
--
1.7.1
From 0a61b5b09ed77bcb1ecde437be37152b33f73d39 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20(Trevi=C3=B1o)?= <m...@3v1n0.net>
Date: Mon, 29 Nov 2010 15:38:15 +0100
Subject: [PATCH 2/2] eve: uri_sanitize function improved, adding file:// protocol support
Added also a check to avoid too-long uri schemas.
---
src/bin/main.c | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/bin/main.c b/src/bin/main.c
index 03dbb38..7fb53b0 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -581,11 +581,27 @@ session_restore(void)
char *
uri_sanitize(const char *uri) {
char *fixed_uri;
+ char *schema;
+ char *tmp;
if (!uri || !*uri) return NULL;
- if (asprintf(&fixed_uri, "%s%s",
- (strstr(uri, "://") ? "" : "http://"), uri) > 0)
- return fixed_uri;
+
+ tmp = strstr(uri, "://");
+ if (!tmp || tmp == uri || tmp > uri+15)
+ {
+ if (ecore_file_exists(uri))
+ schema = "file";
+ else
+ schema = "http";
+
+ if (asprintf(&fixed_uri, "%s://%s", schema, uri) > 0)
+ return fixed_uri;
+ }
+ else
+ {
+ return strdup(uri);
+ }
+
return NULL;
}
--
1.7.1
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel