[planner] Properly handle file paths containing a colon (bug #602427)



commit 5329e3b9e9075963be2a411d2718708ae6106b43
Author: Maurice van der Pot <griffon26 kfk4ever com>
Date:   Tue Nov 24 22:06:14 2009 +0100

    Properly handle file paths containing a colon (bug #602427)
    
    Use g_uri_parse_scheme to figure out the scheme of a path passed to
    mrp_project_load. File paths like "/home/user/c:/myfile.planner" will
    now no longer be rejected.

 libplanner/mrp-project.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/libplanner/mrp-project.c b/libplanner/mrp-project.c
index 4130174..43065e4 100644
--- a/libplanner/mrp-project.c
+++ b/libplanner/mrp-project.c
@@ -682,7 +682,8 @@ mrp_project_load (MrpProject *project, const gchar *uri, GError **error)
 	GList          *l;
 	MrpCalendar    *old_default_calendar;
 	gchar          *file_str;
-	size_t          len;
+	gchar          *scheme;
+	gboolean	is_file_scheme;
 
 	g_return_val_if_fail (MRP_IS_PROJECT (project), FALSE);
 	g_return_val_if_fail (uri != NULL, FALSE);
@@ -699,14 +700,12 @@ mrp_project_load (MrpProject *project, const gchar *uri, GError **error)
 	 */
 	old_default_calendar = priv->calendar;
 
+	scheme = g_uri_parse_scheme(uri);
+	if (scheme != NULL) {
+		is_file_scheme = !strcmp (scheme, "file");
+		g_free (scheme);
 
-	len = strlen (uri);
-
-	/* Get a local file from the uri. */
-	if (len > 3 && !strstr (uri, ":/")) {
-		/* No protocol. */
-	} else {
-		if (len > 7 && !strncmp (uri, "file:/", 6)) {
+		if (is_file_scheme) {
 			/* Naively strip method. */
 			uri = uri + 7;
 		} else {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]