[totem-pl-parser] Fix parsing problems with remote RSS feeds



commit c67f3399232ba574312e115c526695b5ebbca3c6
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Aug 30 15:05:06 2011 +0100

    Fix parsing problems with remote RSS feeds
    
    That were being ignored because XML files are a sub-class
    of text/plain files, and we really don't want text/plain files.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=655378

 plparse/tests/parser.c    |   12 ++++++++++++
 plparse/totem-pl-parser.c |    5 ++++-
 2 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/plparse/tests/parser.c b/plparse/tests/parser.c
index e636931..85c8227 100644
--- a/plparse/tests/parser.c
+++ b/plparse/tests/parser.c
@@ -597,6 +597,17 @@ test_parsing_broken_asx (void)
 }
 
 static void
+test_xml_is_text_plain (void)
+{
+	TotemPlParserResult result;
+
+	g_test_bug ("655378");
+	result = simple_parser_test ("http://leoville.tv/podcasts/floss.xml";);
+	g_message ("result %d", result);
+	g_assert (result == TOTEM_PL_PARSER_RESULT_SUCCESS);
+}
+
+static void
 test_parsing_out_of_order_asx (void)
 {
 	char *uri;
@@ -959,6 +970,7 @@ main (int argc, char *argv[])
 		g_test_add_func ("/parser/resolution", test_resolution);
 		g_test_add_func ("/parser/parsability", test_parsability);
 		g_test_add_func ("/parser/videosite", test_videosite);
+		g_test_add_func ("/parser/xml_is_text_plain", test_xml_is_text_plain);
 		g_test_add_func ("/parser/parsing/hadess", test_parsing_hadess);
 		g_test_add_func ("/parser/parsing/nonexistent_files", test_parsing_nonexistent_files);
 		g_test_add_func ("/parser/parsing/broken_asx", test_parsing_broken_asx);
diff --git a/plparse/totem-pl-parser.c b/plparse/totem-pl-parser.c
index a92a495..396611a 100644
--- a/plparse/totem-pl-parser.c
+++ b/plparse/totem-pl-parser.c
@@ -1911,7 +1911,10 @@ 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 && g_content_type_is_a (mimetype, "text/plain")) {
+				if (mimetype != NULL &&
+				    g_content_type_is_a (mimetype, "text/plain") &&
+				    g_content_type_is_a (mimetype, "application/xml") == FALSE) {
+					DEBUG(file, g_print ("Ignoring URI '%s' dual type because '%s' is a text/plain\n", uri, mimetype));
 					ret = TOTEM_PL_PARSER_RESULT_IGNORED;
 					g_free (mimetype);
 					mimetype = NULL;



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