totem r5756 - in trunk: . browser-plugin
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: totem r5756 - in trunk: . browser-plugin
- Date: Wed, 8 Oct 2008 16:26:33 +0000 (UTC)
Author: hadess
Date: Wed Oct 8 16:26:33 2008
New Revision: 5756
URL: http://svn.gnome.org/viewvc/totem?rev=5756&view=rev
Log:
2008-10-08 Bastien Nocera <hadess hadess net>
* browser-plugin/totem-plugin-viewer.c (relative_uri_remove_query),
(resolve_uri): g_file_resolve_relative_path() doesn't handle queries
(or fragments, but we don't care about them), so work around that
fact. Fixes resolution of filenames when they have a '?' in their
name (Helps: #555417)
Modified:
trunk/ChangeLog
trunk/browser-plugin/totem-plugin-viewer.c
Modified: trunk/browser-plugin/totem-plugin-viewer.c
==============================================================================
--- trunk/browser-plugin/totem-plugin-viewer.c (original)
+++ trunk/browser-plugin/totem-plugin-viewer.c Wed Oct 8 16:26:33 2008
@@ -663,45 +663,85 @@
}
static char *
+relative_uri_remove_query (const char *uri, char **query)
+{
+ char *qmark;
+
+ /* Look for '?' */
+ qmark = strrchr (uri, '?');
+ if (qmark == NULL)
+ return NULL;
+
+ *query = g_strdup (qmark);
+ return g_strndup (uri, qmark - uri);
+}
+
+static char *
resolve_uri (const char *base_uri,
- const char *relative_uri)
+ const char *relative_uri)
{
- char *uri, *scheme;
- GFile *base_gfile, *base_parent_gfile, *resolved_gfile;
+ char *uri, *scheme, *query, *new_relative_uri;
+ GFile *base_gfile, *base_parent_gfile, *resolved_gfile;
+
+ if (!relative_uri)
+ return g_strdup (base_uri);
- if (!relative_uri)
- return g_strdup (base_uri);
+ if (!base_uri)
+ return g_strdup (relative_uri);
- if (!base_uri)
- return g_strdup (relative_uri);
-
- /* If |relative_uri| has a scheme, it's a full URI, just return it */
- scheme = g_uri_parse_scheme (relative_uri);
- if (scheme) {
- g_free (scheme);
- return g_strdup (relative_uri);
- }
-
- base_gfile = g_file_new_for_uri (base_uri);
- base_parent_gfile = g_file_get_parent (base_gfile);
- if (!base_parent_gfile) {
- g_print ("Base URI %s has no parent!\n", base_uri);
- g_object_unref (base_gfile);
- return NULL;
- }
- g_object_unref (base_gfile);
-
- resolved_gfile = g_file_resolve_relative_path (base_parent_gfile, relative_uri);
- g_object_unref (base_parent_gfile);
- if (!resolved_gfile) {
- g_warning ("Failed to resolve relative URI '%s' against base '%s'\n", relative_uri, base_uri);
- return NULL;
- }
+ /* If |relative_uri| has a scheme, it's a full URI, just return it */
+ scheme = g_uri_parse_scheme (relative_uri);
+ if (scheme) {
+ g_free (scheme);
+ return g_strdup (relative_uri);
+ }
- uri = g_file_get_uri (resolved_gfile);
- g_object_unref (resolved_gfile);
+ base_gfile = g_file_new_for_uri (base_uri);
+ base_parent_gfile = g_file_get_parent (base_gfile);
+ if (!base_parent_gfile) {
+ g_print ("Base URI %s has no parent!\n", base_uri);
+ g_object_unref (base_gfile);
+ return NULL;
+ }
+ g_object_unref (base_gfile);
- return uri;
+ query = NULL;
+ new_relative_uri = relative_uri_remove_query (relative_uri, &query);
+
+ if (new_relative_uri) {
+ char *tmpuri;
+
+ resolved_gfile = g_file_resolve_relative_path (base_parent_gfile, new_relative_uri);
+ g_object_unref (base_parent_gfile);
+ if (!resolved_gfile) {
+ g_warning ("Failed to resolve relative URI '%s' against base '%s'\n", relative_uri, base_uri);
+ g_free (new_relative_uri);
+ g_free (query);
+ return NULL;
+ }
+
+ tmpuri = g_file_get_uri (resolved_gfile);
+ g_object_unref (resolved_gfile);
+ uri = g_strdup_printf ("%s%s", tmpuri, query);
+
+ g_free (tmpuri);
+ g_free (new_relative_uri);
+ g_free (query);
+
+ return uri;
+ } else {
+ resolved_gfile = g_file_resolve_relative_path (base_parent_gfile, relative_uri);
+ g_object_unref (base_parent_gfile);
+ if (!resolved_gfile) {
+ g_warning ("Failed to resolve relative URI '%s' against base '%s'\n", relative_uri, base_uri);
+ return NULL;
+ }
+
+ uri = g_file_get_uri (resolved_gfile);
+ g_object_unref (resolved_gfile);
+
+ return uri;
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]