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



commit 0e3d58f61615c6a6a9c4a27ee58fd545e18fe7c3
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 f977e65..2677d87 100644
--- a/plparse/tests/Makefile.am
+++ b/plparse/tests/Makefile.am
@@ -55,4 +55,5 @@ EXTRA_DIST =			\
 	asf-with-asx-suffix.asx	\
 	remote_xspf.php		\
 	HackerMedley		\
-	3gpp-file.mp4
+	3gpp-file.mp4		\
+	really-flv.mp4
diff --git a/plparse/tests/parser.c b/plparse/tests/parser.c
index 031a15c..181d319 100644
--- a/plparse/tests/parser.c
+++ b/plparse/tests/parser.c
@@ -414,6 +414,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;
@@ -636,6 +647,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 15c7914..3669fae 100644
--- a/plparse/totem-pl-parser.c
+++ b/plparse/totem-pl-parser.c
@@ -231,7 +231,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),
@@ -1916,7 +1915,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;
@@ -1926,7 +1925,7 @@ totem_pl_parser_parse_internal (TotemPlParser *parser,
 				func = totem_pl_parser_get_function_for_mimetype (mimetype);
 				if (func == NULL && mimetype != 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]