r16400 - gnucash/trunk/src/gnome-utils - Let gnc_html_parse_url grok Windows filenames, #462567.

Andreas Köhler andi5 at cvs.gnucash.org
Tue Aug 7 06:28:49 EDT 2007


Author: andi5
Date: 2007-08-07 06:28:47 -0400 (Tue, 07 Aug 2007)
New Revision: 16400
Trac: http://svn.gnucash.org/trac/changeset/16400

Modified:
   gnucash/trunk/src/gnome-utils/gnc-html.c
Log:
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.


Modified: gnucash/trunk/src/gnome-utils/gnc-html.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-html.c	2007-08-07 01:00:56 UTC (rev 16399)
+++ gnucash/trunk/src/gnome-utils/gnc-html.c	2007-08-07 10:28:47 UTC (rev 16400)
@@ -169,7 +169,7 @@
 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 @@
  
   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 @@
     /* 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);
     }



More information about the gnucash-changes mailing list