[totem-pl-parser] Ignore leading spaces before EXTINF comments
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem-pl-parser] Ignore leading spaces before EXTINF comments
- Date: Wed, 6 Oct 2010 08:42:11 +0000 (UTC)
commit 438b39af2a4be2ac2ed050585de367121d6901da
Author: Bastien Nocera <hadess hadess net>
Date: Wed Oct 6 09:41:28 2010 +0100
Ignore leading spaces before EXTINF comments
https://bugzilla.gnome.org/show_bug.cgi?id=631497
plparse/tests/Makefile.am | 3 +-
...Gotta_girlfriend_Feat._O_G_Money_Snoop_Dogg.m3u | 3 ++
plparse/tests/parser.c | 11 ++++++
plparse/totem-pl-parser-lines.c | 38 ++++++++++++--------
4 files changed, 39 insertions(+), 16 deletions(-)
---
diff --git a/plparse/tests/Makefile.am b/plparse/tests/Makefile.am
index 4617b58..68f7c69 100644
--- a/plparse/tests/Makefile.am
+++ b/plparse/tests/Makefile.am
@@ -63,4 +63,5 @@ EXTRA_DIST = \
3gpp-file.mp4 \
really-flv.mp4 \
audio.php \
- big5.smi
+ big5.smi \
+ O_G_Money_-_Girl_Gotta_girlfriend_Feat._O_G_Money_Snoop_Dogg.m3u
diff --git a/plparse/tests/O_G_Money_-_Girl_Gotta_girlfriend_Feat._O_G_Money_Snoop_Dogg.m3u b/plparse/tests/O_G_Money_-_Girl_Gotta_girlfriend_Feat._O_G_Money_Snoop_Dogg.m3u
new file mode 100644
index 0000000..cdf0a2a
--- /dev/null
+++ b/plparse/tests/O_G_Money_-_Girl_Gotta_girlfriend_Feat._O_G_Money_Snoop_Dogg.m3u
@@ -0,0 +1,3 @@
+#EXTM3U
+ #EXTINF:-1,O G Money - Girl Gotta girlfriend Feat. O G Money, Snoop Dogg
+http://media.ArtistServer.com/tracks/23985/21898/1/1/5e302b19727b666f5825/0/O_G_Money_-_Girl_Gotta_girlfriend_Feat_O_G_Money,_Snoop_Dogg.mp3
diff --git a/plparse/tests/parser.c b/plparse/tests/parser.c
index 58b4da3..903047f 100644
--- a/plparse/tests/parser.c
+++ b/plparse/tests/parser.c
@@ -461,6 +461,16 @@ test_smi_starttime (void)
}
static void
+test_m3u_leading_tabs (void)
+{
+ char *uri;
+ /* From http://media.artistserver.com/tracks/23985/21898/1/1/1/O_G_Money_-_Girl_Gotta_girlfriend_Feat._O_G_Money_Snoop_Dogg.m3u */
+ uri = get_relative_uri (TEST_SRCDIR "O_G_Money_-_Girl_Gotta_girlfriend_Feat._O_G_Money_Snoop_Dogg.m3u");
+ g_assert_cmpstr (parser_test_get_entry_field (uri, TOTEM_PL_PARSER_FIELD_TITLE), ==, "O G Money - Girl Gotta girlfriend Feat. O G Money, Snoop Dogg");
+ g_free (uri);
+}
+
+static void
test_parsing_rtsp_text_multi (void)
{
char *uri;
@@ -812,6 +822,7 @@ main (int argc, char *argv[])
g_test_add_func ("/parser/parsing/lastfm-attributes", test_lastfm_parsing);
g_test_add_func ("/parser/parsing/m3u_separator", test_m3u_separator);
g_test_add_func ("/parser/parsing/smi_starttime", test_smi_starttime);
+ g_test_add_func ("/parser/parsing/m3u_leading_tabs", test_m3u_leading_tabs);
return g_test_run ();
}
diff --git a/plparse/totem-pl-parser-lines.c b/plparse/totem-pl-parser-lines.c
index b2bb7e9..46719d9 100644
--- a/plparse/totem-pl-parser-lines.c
+++ b/plparse/totem-pl-parser-lines.c
@@ -386,44 +386,52 @@ totem_pl_parser_add_m3u (TotemPlParser *parser,
num_lines--;
for (i = 0; lines[i] != NULL; i++) {
- if (lines[i][0] == '\0')
+ const char *line;
+
+ line = lines[i];
+
+ if (line[0] == '\0')
continue;
retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
+ /* Ignore leading spaces */
+ for (; g_ascii_isspace (line[0]); line++)
+ ;
+
/* Ignore comments, but mark it if we have extra info */
- if (lines[i][0] == '#') {
- if (extinfo == NULL && g_str_has_prefix (lines[i], EXTINF) != FALSE)
- extinfo = lines[i];
+ if (line[0] == '#') {
+ if (extinfo == NULL && g_str_has_prefix (line, EXTINF) != FALSE)
+ extinfo = line;
continue;
}
/* Either it's a URI, or it has a proper path ... */
- if (strstr(lines[i], "://") != NULL
- || lines[i][0] == G_DIR_SEPARATOR) {
+ if (strstr(line, "://") != NULL
+ || line[0] == G_DIR_SEPARATOR) {
GFile *uri;
- uri = g_file_new_for_commandline_arg (lines[i]);
+ uri = g_file_new_for_commandline_arg (line);
if (totem_pl_parser_parse_internal (parser, uri, NULL, parse_data) != TOTEM_PL_PARSER_RESULT_SUCCESS) {
- totem_pl_parser_add_one_uri (parser, lines[i],
+ totem_pl_parser_add_one_uri (parser, line,
totem_pl_parser_get_extinfo_title (extinfo));
}
g_object_unref (uri);
extinfo = NULL;
- } else if (g_ascii_isalpha (lines[i][0]) != FALSE
- && g_str_has_prefix (lines[i] + 1, ":\\")) {
+ } else if (g_ascii_isalpha (line[0]) != FALSE
+ && g_str_has_prefix (line + 1, ":\\")) {
/* Path relative to a drive on Windows, we need to use
* the base that was passed to us */
GFile *uri;
lines[i] = g_strdelimit (lines[i], "\\", '/');
/* + 2, skip drive letter */
- uri = g_file_get_child (base_file, lines[i] + 2);
+ uri = g_file_get_child (base_file, line + 2);
totem_pl_parser_add_one_file (parser, uri,
totem_pl_parser_get_extinfo_title (extinfo));
g_object_unref (uri);
extinfo = NULL;
- } else if (lines[i][0] == '\\' && lines[i][1] == '\\') {
+ } else if (line[0] == '\\' && line[1] == '\\') {
/* ... Or it's in the windows smb form
* (\\machine\share\filename), Note drive names
* (C:\ D:\ etc) are unhandled (unknown base for
@@ -431,9 +439,9 @@ totem_pl_parser_add_m3u (TotemPlParser *parser,
char *tmpuri;
lines[i] = g_strdelimit (lines[i], "\\", '/');
- tmpuri = g_strjoin (NULL, "smb:", lines[i], NULL);
+ tmpuri = g_strjoin (NULL, "smb:", line, NULL);
- totem_pl_parser_add_one_uri (parser, lines[i],
+ totem_pl_parser_add_one_uri (parser, line,
totem_pl_parser_get_extinfo_title (extinfo));
extinfo = NULL;
@@ -447,7 +455,7 @@ totem_pl_parser_add_m3u (TotemPlParser *parser,
sep = (dos_mode ? '\\' : '/');
if (sep == '\\')
lines[i] = g_strdelimit (lines[i], "\\", '/');
- uri = g_file_get_child (_base_file, lines[i]);
+ uri = g_file_get_child (_base_file, line);
g_object_unref (_base_file);
totem_pl_parser_add_one_file (parser, uri,
totem_pl_parser_get_extinfo_title (extinfo));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]