Commit 0a64e71e authored by Bastien Nocera's avatar Bastien Nocera

Bug 579716 – totem-plugin-viewer crashed with SIGSEGV in strchr()

2009-04-22  Bastien Nocera  <hadess@hadess.net>

	* browser-plugin/totem-plugin-viewer.c (totem_embedded_set_uri):
	* configure.in: Use the new URI resolution code in totem-pl-parser
	and fix crasher when opening a video at the root of a webserver
	(Closes: #579716)
parent e8200e5f
2009-04-22 Bastien Nocera <hadess@hadess.net>
* browser-plugin/totem-plugin-viewer.c (totem_embedded_set_uri):
* configure.in: Use the new URI resolution code in totem-pl-parser
and fix crasher when opening a video at the root of a webserver
(Closes: #579716)
2009-04-21 Bastien Nocera <hadess@hadess.net>
* data/totem.1: Remove out-dated options from the man page
......
......@@ -58,6 +58,10 @@ GtkWidget *totem_statusbar_create (void);
GtkWidget *totem_volume_create (void);
GtkWidget *totem_pp_create (void);
/* Private function in totem-pl-parser, not for use
* by anyone but us */
char * totem_pl_parser_resolve_uri (GFile *base_gfile, const char *relative_uri);
#define VOLUME_DOWN_OFFSET (-0.08)
#define VOLUME_UP_OFFSET (0.08)
#define MINIMUM_VIDEO_SIZE 150
......@@ -661,102 +665,26 @@ totem_embedded_launch_player (TotemEmbedded *embedded,
return result;
}
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)
{
char *uri, *scheme, *query, *new_relative_uri;
GFile *base_gfile, *base_parent_gfile, *resolved_gfile;
if (!relative_uri)
return g_strdup (base_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);
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
totem_embedded_set_uri (TotemEmbedded *emb,
const char *uri,
const char *base_uri,
gboolean is_browser_stream)
{
GFile *base_gfile;
char *old_uri, *old_base, *old_href;
base_gfile = NULL;
old_uri = emb->current_uri;
old_base = emb->base_uri;
old_href = emb->href_uri;
emb->base_uri = g_strdup (base_uri);
emb->current_uri = resolve_uri (base_uri, uri);
if (base_uri)
base_gfile = g_file_new_for_uri (base_uri);
emb->current_uri = totem_pl_parser_resolve_uri (base_gfile, uri);
if (base_gfile)
g_object_unref (base_gfile);
emb->is_browser_stream = (is_browser_stream != FALSE);
emb->href_uri = NULL;
......
......@@ -35,7 +35,7 @@ AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums])
# Requirements
GLIB_REQS=2.13.4
GTK_REQS=2.16.0
TOTEM_PLPARSER_REQS=2.23.91
TOTEM_PLPARSER_REQS=2.27.0
GNOMEICON_REQS=2.15.90
DBUS_REQS=0.61
VALA_REQS=0.1.6
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment