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
This commit is contained in:
Andreas Köhler
2007-08-07 10:28:47 +00:00
parent a5b6c728ff
commit 84a9378d0b

View File

@@ -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);
}