Il giorno mar, 30/11/2010 alle 10.37 -0200, Leandro Pereira ha scritto:
> On Mon, Nov 29, 2010 at 10:09 PM, Marco Trevisan (Treviño)
> <[email protected]> wrote:
> > In previous patches I forgot to use the file absolute path when
> > processing a file:// schema. Webkit doesn't work with relative paths, so
> > this is needed for opening something with "eve my_file.html"
>
> Applied with minor changes -- ecore_file_realpath() returns a
> newly-allocated string so it must be properly freed.
Thanks.
I've also another version for this function, this one supports any
protocol, following the syntax rules stated by the RFC 3986 considering
everything that precedes a semicolon (:) as the schema, and the rest as
the path (this allows to get working about:* pages too, also if
webkit-efl doesn't seem to support them yet). However I had to check
that the "parsed" schema was not actually a port number or a password
(with urls like www.google.com:80 or http://user:[email protected]:80 ;)
All the cases I've tested seem to work, let me know what you think.
Bye.
From 3f83bbc181a51397c32fbca4f587ccf3e126e515 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20(Trevi=C3=B1o)?= <[email protected]>
Date: Wed, 1 Dec 2010 18:38:44 +0100
Subject: [PATCH] eve: even better uri_sanitize function.
It supports any protocol according the RFC 3986, checking for valid syntax
---
src/bin/main.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/src/bin/main.c b/src/bin/main.c
index 6820c50..a6c7bc0 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -580,14 +580,60 @@ session_restore(void)
char *
uri_sanitize(const char *uri) {
+ Eina_Bool invalid;
char *fixed_uri;
char *schema;
char *tmp;
+ int i;
if (!uri || !*uri) return NULL;
- tmp = strstr(uri, "://");
- if (!tmp || (tmp == uri) || (tmp > (uri + 15)))
+ invalid = EINA_FALSE;
+
+ tmp = strchr(uri, ':');
+
+ if (!tmp || tmp == uri || tmp-uri > 15)
+ {
+ invalid = EINA_TRUE;
+ } else {
+ /* check if this is a valid schema */
+ for (i = 0; i < tmp-uri && !invalid; i++)
+ {
+ if (!isalnum(uri[i]) && uri[i] != '+' &&
+ uri[i] != '-' && uri[i] != '.')
+ {
+ invalid = EINA_TRUE;
+ }
+ }
+
+ /* check if the parsed schema is the port, in fact */
+ if (!invalid)
+ {
+ i = tmp-uri+1;
+ while (isdigit(uri[i]) && uri[i] != '\0')
+ {
+ i++;
+ }
+
+ if (i > tmp-uri+1 && (uri[i] == '/' || uri[i] == '?' || uri[i] == '\0'))
+ invalid = EINA_TRUE;
+ }
+
+ /* check if the parsed schema is a password, in fact */
+ if (!invalid)
+ {
+ i = tmp-uri+1;
+ while (isalnum(uri[i]) && uri[i] != '\0')
+ {
+ i++;
+ }
+
+ if (i > tmp-uri+1 && uri[i] == '@' && strlen(uri) > i && uri[i+1] != '\0')
+ invalid = EINA_TRUE;
+ }
+ }
+
+ if (invalid)
{
char *new_uri = NULL;
if (ecore_file_exists(uri))
--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel