[totem-pl-parser] Make sure videos disguised as MP4 aren't unhandled



commit 027d97f6b1624bb3e9913ca5f7981a17eb457fc3
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Sep 13 14:32:17 2010 +0100

    Make sure videos disguised as MP4 aren't unhandled
    
    *.mp4 files were ignored if they were actually detected
    as any other type. This was the case for 3gpp files, but
    it would happen for *all* files types that weren't listed.
    
    And we can't list every file type as possibly being a quicktime file.
    
    So we ignore files that are text/plain, or a sub-class of it.
    
    This makes FLV hiding as an MP4, or 3GPP hiding as an MP4 work
    correctly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=620039

 plparse/tests/Makefile.am    |    3 ++-
 plparse/tests/parser.c       |   12 ++++++++++++
 plparse/tests/really-flv.mp4 |  Bin 0 -> 204800 bytes
 plparse/totem-pl-parser.c    |    5 ++---
 4 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/plparse/tests/Makefile.am b/plparse/tests/Makefile.am
index ce0fdb1..f9e143e 100644
--- a/plparse/tests/Makefile.am
+++ b/plparse/tests/Makefile.am
@@ -60,4 +60,5 @@ EXTRA_DIST =			\
 	new-lastfm-output.xspf	\
 	old-lastfm-output.xspf	\
 	separator.m3u		\
-	3gpp-file.mp4
+	3gpp-file.mp4		\
+	really-flv.mp4
diff --git a/plparse/tests/parser.c b/plparse/tests/parser.c
index 9bfbfdb..acd3046 100644
--- a/plparse/tests/parser.c
+++ b/plparse/tests/parser.c
@@ -542,6 +542,17 @@ test_parsing_3gpp_not_ignored (void)
 }
 
 static void
+test_parsing_mp4_is_flv (void)
+{
+	char *uri;
+
+	uri = get_relative_uri (TEST_SRCDIR "really-flv.mp4");
+	g_test_bug ("620039");
+	g_assert (simple_parser_test (uri) == TOTEM_PL_PARSER_RESULT_UNHANDLED);
+	g_free (uri);
+}
+
+static void
 test_parsing_xml_head_comments (void)
 {
 	char *uri;
@@ -775,6 +786,7 @@ main (int argc, char *argv[])
 		g_test_add_func ("/parser/parsing/broken_asx", test_parsing_broken_asx);
 		g_test_add_func ("/parser/parsing/404_error", test_parsing_404_error);
 		g_test_add_func ("/parser/parsing/3gpp_not_ignored", test_parsing_3gpp_not_ignored);
+		g_test_add_func ("/parser/parsing/mp4_is_flv", test_parsing_mp4_is_flv);
 		g_test_add_func ("/parser/parsing/out_of_order_asx", test_parsing_out_of_order_asx);
 		g_test_add_func ("/parser/parsing/xml_head_comments", test_parsing_xml_head_comments);
 		g_test_add_func ("/parser/parsing/xml_comment_whitespace", test_parsing_xml_comment_whitespace);
diff --git a/plparse/tests/really-flv.mp4 b/plparse/tests/really-flv.mp4
new file mode 100644
index 0000000..e445e30
Binary files /dev/null and b/plparse/tests/really-flv.mp4 differ
diff --git a/plparse/totem-pl-parser.c b/plparse/totem-pl-parser.c
index 4308aa6..ec32b70 100644
--- a/plparse/totem-pl-parser.c
+++ b/plparse/totem-pl-parser.c
@@ -232,7 +232,6 @@ static PlaylistTypes dual_types[] = {
 	PLAYLIST_TYPE2 ("video/x-ms-wmv", totem_pl_parser_add_asf, totem_pl_parser_is_asf),
 	PLAYLIST_TYPE2 ("video/quicktime", totem_pl_parser_add_quicktime, totem_pl_parser_is_quicktime),
 	PLAYLIST_TYPE2 ("video/mp4", totem_pl_parser_add_quicktime, totem_pl_parser_is_quicktime),
-	PLAYLIST_TYPE2 ("video/3gpp", totem_pl_parser_add_quicktime, totem_pl_parser_is_quicktime),
 	PLAYLIST_TYPE2 ("application/x-quicktime-media-link", totem_pl_parser_add_quicktime, totem_pl_parser_is_quicktime),
 	PLAYLIST_TYPE2 ("application/x-quicktimeplayer", totem_pl_parser_add_quicktime, totem_pl_parser_is_quicktime),
 	PLAYLIST_TYPE2 ("application/xml", totem_pl_parser_add_xml_feed, totem_pl_parser_is_xml_feed),
@@ -1889,7 +1888,7 @@ totem_pl_parser_parse_internal (TotemPlParser *parser,
 					DEBUG(file, g_print ("URI '%s' dual type has type '%s' from data\n", uri, mimetype));
 				}
 				/* If it's _still_ a text/plain, we don't want it */
-				if (mimetype != NULL && strcmp (mimetype, "text/plain") == 0) {
+				if (mimetype != NULL && g_content_type_is_a (mimetype, "text/plain")) {
 					ret = TOTEM_PL_PARSER_RESULT_IGNORED;
 					g_free (mimetype);
 					mimetype = NULL;
@@ -1899,7 +1898,7 @@ totem_pl_parser_parse_internal (TotemPlParser *parser,
 				func = totem_pl_parser_get_function_for_mimetype (mimetype);
 				if ((func == NULL && mimetype != NULL) || (mimetype == NULL && dual_types[i].func == NULL)) {
 					DEBUG(file, g_print ("Ignoring URI '%s' because we couldn't find a playlist parser for '%s'\n", uri, mimetype));
-					ret = TOTEM_PL_PARSER_RESULT_IGNORED;
+					ret = TOTEM_PL_PARSER_RESULT_UNHANDLED;
 					g_free (mimetype);
 					mimetype = NULL;
 					break;



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