[libsoup] Fix sniffing of un-Content-Typed XML



commit 46a777a879a877ee9306beee0876a51a67b95ed5
Author: Dan Winship <danw gnome org>
Date:   Mon Jul 3 09:37:40 2017 -0400

    Fix sniffing of un-Content-Typed XML
    
    https://bugs.webkit.org/show_bug.cgi?id=173923

 libsoup/soup-content-sniffer.c |    2 +-
 tests/resources/misc.xml       |   11 +++++++++++
 tests/sniffing-test.c          |    4 ++++
 tests/soup-tests.gresource.xml |    1 +
 4 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/libsoup/soup-content-sniffer.c b/libsoup/soup-content-sniffer.c
index 1517782..8b4b805 100644
--- a/libsoup/soup-content-sniffer.c
+++ b/libsoup/soup-content-sniffer.c
@@ -420,7 +420,7 @@ static SoupContentSnifferPattern types_table[] = {
          (const guchar *)"\x00\xFF\xFF\xFF\xFF\xFF",
          (const guchar *)" <?xml",
          5,
-         "text/html",
+         "text/xml",
          TRUE },
 
        { FALSE, FALSE,
diff --git a/tests/resources/misc.xml b/tests/resources/misc.xml
new file mode 100644
index 0000000..15361e6
--- /dev/null
+++ b/tests/resources/misc.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource>
+    <file compressed="true">test1.txt</file>
+    <file preprocess="xml-stripblanks">test.gresource.xml</file>
+  </gresource>
+  <gresource prefix="/a_prefix">
+    <file alias="test2-alias.txt">test2.txt</file>
+    <file>test2.txt</file>
+  </gresource>
+</gresources>
diff --git a/tests/sniffing-test.c b/tests/sniffing-test.c
index 1e8680b..7b39117 100644
--- a/tests/sniffing-test.c
+++ b/tests/sniffing-test.c
@@ -528,6 +528,10 @@ main (int argc, char **argv)
        g_test_add_data_func ("/sniffing/type/unknown-leading-space",
                              "unknown/leading_space.html => text/html",
                              do_sniffing_test);
+       /* https://bugs.webkit.org/show_bug.cgi?id=173923 */
+       g_test_add_data_func ("/sniffing/type/unknown-xml",
+                             "unknown/misc.xml => text/xml",
+                             do_sniffing_test);
 
        /* Test the XML sniffing path */
        g_test_add_data_func ("/sniffing/type/xml",
diff --git a/tests/soup-tests.gresource.xml b/tests/soup-tests.gresource.xml
index b24a729..9c08d17 100644
--- a/tests/soup-tests.gresource.xml
+++ b/tests/soup-tests.gresource.xml
@@ -13,6 +13,7 @@
     <file>resources/mbox.gz</file>
     <file>resources/mbox.raw</file>
     <file>resources/mbox.zlib</file>
+    <file>resources/misc.xml</file>
     <file>resources/ps_binary.ps</file>
     <file>resources/rss20.xml</file>
     <file>resources/test.aiff</file>


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