[totem-pl-parser] plparse: Don't overescape parse URIs in XSPF
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem-pl-parser] plparse: Don't overescape parse URIs in XSPF
- Date: Mon, 29 Oct 2012 10:22:20 +0000 (UTC)
commit feeb3d38ae02e1ff9bdf5e8e9fbb2800e0849845
Author: Bastien Nocera <hadess hadess net>
Date: Mon Oct 29 08:22:10 2012 +0100
plparse: Don't overescape parse URIs in XSPF
Passing a URI through g_file_new()/g_file_get_uri() will
create escaping problems if the original URI contained spaces
on purpose (for example, rtmp URLs with additional parameters).
Original patch by GyÃrgy Ballà <ballogy freestart hu>
https://bugzilla.gnome.org/show_bug.cgi?id=687088
plparse/tests/parser.c | 10 +++++++
plparse/tests/playlist.xspf | 2 +-
plparse/totem-pl-parser-xspf.c | 52 +++++++++++++++++++++++++++-------------
3 files changed, 46 insertions(+), 18 deletions(-)
---
diff --git a/plparse/tests/parser.c b/plparse/tests/parser.c
index 2350a1c..48882f9 100644
--- a/plparse/tests/parser.c
+++ b/plparse/tests/parser.c
@@ -513,6 +513,15 @@ test_parsing_xspf_genre (void)
}
static void
+test_parsing_xspf_escaping (void)
+{
+ char *uri;
+ uri = get_relative_uri (TEST_SRCDIR "playlist.xspf");
+ g_assert_cmpstr (parser_test_get_entry_field (uri, TOTEM_PL_PARSER_FIELD_URI), ==, "http://207.200.96.226:8000 extraparam=1");
+ g_free (uri);
+}
+
+static void
test_smi_starttime (void)
{
char *uri;
@@ -1138,6 +1147,7 @@ main (int argc, char *argv[])
g_test_add_func ("/parser/parsing/not_really_php_but_html_instead", test_parsing_not_really_php_but_html_instead);
g_test_add_func ("/parser/parsing/num_items_in_pls", test_parsing_num_entries);
g_test_add_func ("/parser/parsing/xspf_genre", test_parsing_xspf_genre);
+ g_test_add_func ("/parser/parsing/xspf_escaping", test_parsing_xspf_escaping);
g_test_add_func ("/parser/parsing/itms_link", test_itms_parsing);
g_test_add_func ("/parser/parsing/lastfm-attributes", test_lastfm_parsing);
g_test_add_func ("/parser/parsing/m3u_separator", test_m3u_separator);
diff --git a/plparse/tests/playlist.xspf b/plparse/tests/playlist.xspf
index 543780d..75cd302 100644
--- a/plparse/tests/playlist.xspf
+++ b/plparse/tests/playlist.xspf
@@ -3,7 +3,7 @@
<creator>audacious-plugins-1.4.5</creator>
<trackList>
<track>
- <location>http://207.200.96.226:8000</location>
+ <location>http://207.200.96.226:8000 extraparam=1</location>
<title>Sven Van Hess - Ocean Jive (Groove Salad: a nicely chilled plate of ambient beats and grooves. [SomaFM])</title>
<meta rel="mtime">0</meta>
<extension application="http://www.rhythmbox.org">
diff --git a/plparse/totem-pl-parser-xspf.c b/plparse/totem-pl-parser-xspf.c
index 7fb264d..02c5217 100644
--- a/plparse/totem-pl-parser-xspf.c
+++ b/plparse/totem-pl-parser-xspf.c
@@ -306,23 +306,41 @@ parse_xspf_track (TotemPlParser *parser, GFile *base_file, xmlDocPtr doc,
}
resolved_uri = totem_pl_parser_resolve_uri (base_file, (char *) uri);
- resolved = g_file_new_for_uri (resolved_uri);
- g_free (resolved_uri);
-
- totem_pl_parser_add_uri (parser,
- TOTEM_PL_PARSER_FIELD_FILE, resolved,
- TOTEM_PL_PARSER_FIELD_TITLE, title,
- TOTEM_PL_PARSER_FIELD_DURATION_MS, duration,
- TOTEM_PL_PARSER_FIELD_IMAGE_URI, image_uri,
- TOTEM_PL_PARSER_FIELD_AUTHOR, artist,
- TOTEM_PL_PARSER_FIELD_ALBUM, album,
- TOTEM_PL_PARSER_FIELD_MOREINFO, moreinfo,
- TOTEM_PL_PARSER_FIELD_DOWNLOAD_URI, download_uri,
- TOTEM_PL_PARSER_FIELD_ID, id,
- TOTEM_PL_PARSER_FIELD_GENRE, genre,
- TOTEM_PL_PARSER_FIELD_FILESIZE, filesize,
- NULL);
- g_object_unref (resolved);
+
+ if (g_strcmp0 (resolved_uri, (char *) uri) == 0) {
+ g_free (resolved_uri);
+ totem_pl_parser_add_uri (parser,
+ TOTEM_PL_PARSER_FIELD_URI, uri,
+ TOTEM_PL_PARSER_FIELD_TITLE, title,
+ TOTEM_PL_PARSER_FIELD_DURATION_MS, duration,
+ TOTEM_PL_PARSER_FIELD_IMAGE_URI, image_uri,
+ TOTEM_PL_PARSER_FIELD_AUTHOR, artist,
+ TOTEM_PL_PARSER_FIELD_ALBUM, album,
+ TOTEM_PL_PARSER_FIELD_MOREINFO, moreinfo,
+ TOTEM_PL_PARSER_FIELD_DOWNLOAD_URI, download_uri,
+ TOTEM_PL_PARSER_FIELD_ID, id,
+ TOTEM_PL_PARSER_FIELD_GENRE, genre,
+ TOTEM_PL_PARSER_FIELD_FILESIZE, filesize,
+ NULL);
+ } else {
+ resolved = g_file_new_for_uri (resolved_uri);
+ g_free (resolved_uri);
+
+ totem_pl_parser_add_uri (parser,
+ TOTEM_PL_PARSER_FIELD_FILE, resolved,
+ TOTEM_PL_PARSER_FIELD_TITLE, title,
+ TOTEM_PL_PARSER_FIELD_DURATION_MS, duration,
+ TOTEM_PL_PARSER_FIELD_IMAGE_URI, image_uri,
+ TOTEM_PL_PARSER_FIELD_AUTHOR, artist,
+ TOTEM_PL_PARSER_FIELD_ALBUM, album,
+ TOTEM_PL_PARSER_FIELD_MOREINFO, moreinfo,
+ TOTEM_PL_PARSER_FIELD_DOWNLOAD_URI, download_uri,
+ TOTEM_PL_PARSER_FIELD_ID, id,
+ TOTEM_PL_PARSER_FIELD_GENRE, genre,
+ TOTEM_PL_PARSER_FIELD_FILESIZE, filesize,
+ NULL);
+ g_object_unref (resolved);
+ }
retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]