Author: jannis Date: 2008-11-20 00:16:56 +0000 (Thu, 20 Nov 2008) New Revision: 28866
Modified: libexo/trunk/ChangeLog libexo/trunk/exo/exo-url.c Log: * exo/exo-url.c (_exo_url_to_local_path, exo_url_show_on_screen): Modify _exo_url_to_local_path() so that it converts file:// URIs to paths, does not touch absolute paths and converts relative paths to absolute paths only if they exist in the local filesystem. Set relative paths to NULL otherwise. Replace the two regular expression for browser URIs by a more generic one and try to open URIs in the following order: file manager, email client and web browser as a last option. Alltogether this should fix bug #4627. Modified: libexo/trunk/ChangeLog =================================================================== --- libexo/trunk/ChangeLog 2008-11-20 00:06:52 UTC (rev 28865) +++ libexo/trunk/ChangeLog 2008-11-20 00:16:56 UTC (rev 28866) @@ -1,3 +1,15 @@ +2008-11-20 Jannis Pohlmann <[EMAIL PROTECTED]> + + * exo/exo-url.c (_exo_url_to_local_path, exo_url_show_on_screen): + Modify _exo_url_to_local_path() so that it converts file:// URIs to + paths, does not touch absolute paths and converts relative paths to + absolute paths only if they exist in the local filesystem. Set + relative paths to NULL otherwise. + Replace the two regular expression for browser URIs by a more + generic one and try to open URIs in the following order: file + manager, email client and web browser as a last option. + Alltogether this should fix bug #4627. + 2008-11-11 Jannis Pohlmann <[EMAIL PROTECTED]> * NEWS: Update NEWS file for the upcoming beta2 release. Modified: libexo/trunk/exo/exo-url.c =================================================================== --- libexo/trunk/exo/exo-url.c 2008-11-20 00:06:52 UTC (rev 28865) +++ libexo/trunk/exo/exo-url.c 2008-11-20 00:16:56 UTC (rev 28866) @@ -56,10 +56,7 @@ #define PASSCHARS "-A-Za-z0-9,?;.:/!%$^*&~\"#'" #define HOSTCHARS "-A-Za-z0-9" #define USER "[" USERCHARS "]+(:["PASSCHARS "]+)?" -#define MATCH_BROWSER1 "^((file|https?|ftps?)://(" USER "@)?)[" HOSTCHARS ".]+(:[0-9]+)?" \ - "(/[-A-Za-z0-9_$.+!*(),;:@&=?/~#%]*[^]'.}>) \t\r\n,\\\"])?$" -#define MATCH_BROWSER2 "^(www|ftp)[" HOSTCHARS "]*\\.[" HOSTCHARS ".]+(:[0-9]+)?" \ - "(/[-A-Za-z0-9_$.+!*(),;:@&=?/~#%]*[^]'.}>) \t\r\n,\\\"])?$" +#define MATCH_BROWSER "^(([^:/?#]+)://)?([^/?#])([^?#]*)(\\?([^#]*))?(#(.*))?" #if !defined(__GLIBC__) #define MATCH_MAILER "[EMAIL PROTECTED](\\.[a-z0-9][a-z0-9-]*)+$" #else @@ -143,12 +140,15 @@ _exo_url_to_local_path (const gchar *url) { gchar *current_dir; - gchar *path; + gchar *path = NULL; - /* transform a file:-URI to a local path */ - path = g_filename_from_uri (url, NULL, NULL); - if (G_LIKELY (path == NULL)) + if (g_str_has_prefix (url, "file://")) { + /* transform a file:-URI to a local path */ + path = g_filename_from_uri (url, NULL, NULL); + } + else + { /* check if url is an absolute path */ if (g_path_is_absolute (url)) { @@ -161,17 +161,17 @@ current_dir = g_get_current_dir (); path = g_build_filename (current_dir, url, NULL); g_free (current_dir); + + /* verify that a file of the given name exists */ + if (!g_file_test (path, G_FILE_TEST_EXISTS)) + { + /* no local path then! */ + g_free (path); + path = NULL; + } } } - /* verify that a file of the given name exists */ - if (!g_file_test (path, G_FILE_TEST_EXISTS)) - { - /* no local path then! */ - g_free (path); - path = NULL; - } - return path; } @@ -291,10 +291,6 @@ /* and we're done */ return result; } - else if (_exo_url_match (MATCH_BROWSER1, url)) - { - category = "WebBrowser"; - } else if (strncmp (url, "mailto:", 7) == 0 || _exo_url_match (MATCH_MAILER, url)) { /* ignore mailto: prefix, as not all mailers can handle it */ @@ -302,9 +298,8 @@ url += 7; category = "MailReader"; } - else if (_exo_url_match (MATCH_BROWSER2, url)) + else if (_exo_url_match (MATCH_BROWSER, url)) { - /* after MATCH_MAILER, see http://bugzilla.xfce.org/show_bug.cgi?id=2530 for details */ category = "WebBrowser"; } else _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits