From 84a9378d0bd4ddea52a9497b31fbed6dd0657b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=B6hler?= Date: Tue, 7 Aug 2007 10:28:47 +0000 Subject: [PATCH] Let gnc_html_parse_url grok Windows filenames, #462567. Change the regular expression that should match the protocol in a given URL so that it requires at least two characters and C:\ or C:/ will not be interpreted as [prot=C, path=\] (or path=/, resp.). Also replace two hard-coded slash operations by g_path_is_absolute and g_build_filename. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16400 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome-utils/gnc-html.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/gnome-utils/gnc-html.c b/src/gnome-utils/gnc-html.c index 479daa4fff..658890fc5c 100644 --- a/src/gnome-utils/gnc-html.c +++ b/src/gnome-utils/gnc-html.c @@ -169,7 +169,7 @@ URLType gnc_html_parse_url(gnc_html * html, const gchar * url, char ** url_location, char ** url_label) { - char uri_rexp[] = "^(([^:]*):)?([^#]+)?(#(.*))?$"; + char uri_rexp[] = "^(([^:][^:]+):)?([^#]+)?(#(.*))?$"; regex_t compiled; regmatch_t match[6]; char * protocol=NULL, * path=NULL, * label=NULL; @@ -232,11 +232,12 @@ gnc_html_parse_url(gnc_html * html, const gchar * url, if (!safe_strcmp (retval, URL_TYPE_FILE)) { if(!found_protocol && path && html && html->base_location) { - if(path[0] == '/') { + if (g_path_is_absolute(path)) { *url_location = g_strdup(path); } else { - *url_location = g_strconcat(html->base_location, "/", path, NULL); + *url_location = + g_build_filename(html->base_location, path, (gchar*)NULL); } g_free(path); } @@ -253,13 +254,14 @@ gnc_html_parse_url(gnc_html * html, const gchar * url, /* case URL_TYPE_OTHER: */ if(!found_protocol && path && html && html->base_location) { - if(path[0] == '/') { - *url_location = - g_strconcat(extract_machine_name(html->base_location), - "/", path+1, NULL); + if (g_path_is_absolute(path)) { + *url_location = + g_build_filename(extract_machine_name(html->base_location), + path, (gchar*)NULL); } else { - *url_location = g_strconcat(html->base_location, path, NULL); + *url_location = + g_build_filename(html->base_location, path, (gchar*)NULL); } g_free(path); }