Re: [E-devel] [PATCH] eve: use file realpath for file:// schema

2010-12-02 Thread Leandro Pereira
On Wed, Dec 1, 2010 at 4:06 PM, Marco Trevisan (Treviño) m...@3v1n0.net wrote:

 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:p...@anysite.com:80 ;)

 All the cases I've tested seem to work, let me know what you think.


I've checked RFC 3896 and it seems that URL parsing isn't as simple as
it sounds. There are libraries there to provide URL parsing and
they're quite complicated because there are lots of ambiguities and
other pitfalls. I don't see any need right now to make this thing
beefier, since the current naive implementation is working fine
already.

Well, except for about: URLs, but I think this is the wrong layer to
put this; there is already a patch to WebKit Soup backend to support
custom scheme handlers, which will also make it possible to embed
external resources (e.g. images).

-- 
Cheers,
  Leandro

--
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


Re: [E-devel] [PATCH] eve: use file realpath for file:// schema

2010-12-01 Thread Treviño
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)
 m...@3v1n0.net 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:p...@anysite.com: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)?= m...@3v1n0.net
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
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [PATCH] eve: use file realpath for file:// schema

2010-11-30 Thread Rui Miguel Silva Seabra
Em 30-11-2010 00:09, Marco Trevisan (Treviño) escreveu:
 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

Will this file:// support allow some javascript code to get file://paths 
? Hope not...

Rui

--
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


Re: [E-devel] [PATCH] eve: use file realpath for file:// schema

2010-11-30 Thread Gustavo Sverzut Barbieri
On Tuesday, November 30, 2010, Rui Miguel Silva Seabra r...@1407.org wrote:
 Em 30-11-2010 00:09, Marco Trevisan (Treviño) escreveu:
 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

 Will this file:// support allow some javascript code to get file://paths
 ? Hope not...

This is just for command line. Everything from inside webkit (js,
links...) goes through a sandbox policy, same for other browsers



-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--
MSN: barbi...@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

--
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


Re: [E-devel] [PATCH] eve: use file realpath for file:// schema

2010-11-30 Thread Leandro Pereira
On Mon, Nov 29, 2010 at 10:09 PM, Marco Trevisan (Treviño)
m...@3v1n0.net 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.

-- 
Cheers,
  Leandro

--
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


[E-devel] [PATCH] eve: use file realpath for file:// schema

2010-11-29 Thread Treviño
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

Bye.
From 3fec8dfb828e39d48a43ca0993573b6e90435b8c 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 17:44:41 +0100
Subject: [PATCH] eve: use the file realpath when processing a file:// schema

---
 src/bin/main.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/bin/main.c b/src/bin/main.c
index 7fb53b0..5475753 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -590,7 +590,10 @@ uri_sanitize(const char *uri) {
if (!tmp || tmp == uri || tmp  uri+15)
  {
 if (ecore_file_exists(uri))
-  schema = file;
+  {
+ schema = file;
+ uri = ecore_file_realpath(uri);
+  }
 else
   schema = http;
 
-- 
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