2006-04-27 Eric Seidel <eseidel@apple.com>
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Apr 2006 10:57:28 +0000 (10:57 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Apr 2006 10:57:28 +0000 (10:57 +0000)
        Reviewed by andersca.

        Make WebCore accept any */*+xml type as XML.
        http://bugzilla.opendarwin.org/show_bug.cgi?id=5998
        <rdar://problem/4031511> XmlHttpRequest doesn't allow responses with Content-Type: application/soap+xml

        Test: http/tests/xmlhttprequest/supported-xml-content-types.html

        * dom/DOMImplementation.cpp:
        (WebCore::DOMImplementation::isXMLMIMEType):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14096 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.cgi [new file with mode: 0755]
LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/DOMImplementation.cpp
WebCore/kcanvas/device/quartz/KCanvasFilterQuartz.mm
WebCore/xml/xmlhttprequest.cpp

index 219148977f75e2ce44e1791059b5974ef0719e9f..6bf6b6e7871929d1b98bb9ea6667c0ac817f3788 100644 (file)
@@ -1,3 +1,14 @@
+2006-04-28  Eric Seidel  <eseidel@apple.com>
+
+        Reviewed by andersca.
+
+        WebKit should accept */*+xml as XML.
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=5998
+
+        * http/tests/xmlhttprequest/supported-xml-content-types-expected.txt: Added.
+        * http/tests/xmlhttprequest/supported-xml-content-types.cgi: Added.
+        * http/tests/xmlhttprequest/supported-xml-content-types.html: Added.
+
 2006-04-27  Geoffrey Garen  <ggaren@apple.com>
 
         - Updated to remove diff shmutz:
diff --git a/LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types-expected.txt b/LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types-expected.txt
new file mode 100644 (file)
index 0000000..482ce91
--- /dev/null
@@ -0,0 +1,81 @@
+PASS -- testing: text/xml -- responseXML: [object Document]
+
+PASS -- testing: image/svg+xml -- responseXML: [object Document]
+
+PASS -- testing: application/soap+xml -- responseXML: [object Document]
+
+PASS -- testing: foo/bar+xml -- responseXML: [object Document]
+
+PASS -- testing: 123/BAR+xml -- responseXML: [object Document]
+
+PASS -- testing: foo_bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: foo-bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: foo+bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: foo~bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: foo!bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: foo$bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: foo^bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: foo{bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: foo}bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: foo|bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: foo%bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: foo'bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: foo`bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: foo#bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: foo&bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: foo*bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: text/html -- responseXML: undefined
+
+PASS -- testing: image/png -- responseXML: undefined
+
+PASS -- testing: invalid -- responseXML: undefined
+
+FAIL (got document -- response type: foo bar/baz+xml) -- testing: foo bar/baz+xml -- responseXML: [object Document]
+
+PASS -- testing: foo[bar/baz+xml -- responseXML: undefined
+
+PASS -- testing: foo]bar/baz+xml -- responseXML: undefined
+
+PASS -- testing: foo(bar/baz+xml -- responseXML: undefined
+
+PASS -- testing: foo)bar/baz+xml -- responseXML: undefined
+
+PASS -- testing: foo
+
+PASS -- testing: foo>bar/baz+xml -- responseXML: undefined
+
+PASS -- testing: foo@bar/baz+xml -- responseXML: undefined
+
+PASS -- testing: foo,bar/baz+xml -- responseXML: undefined
+
+PASS -- testing: foo;bar/baz+xml -- responseXML: undefined
+
+PASS -- testing: foo:bar/baz+xml -- responseXML: undefined
+
+PASS -- testing: foo\bar/baz+xml -- responseXML: undefined
+
+PASS -- testing: foo"bar/baz+xml -- responseXML: undefined
+
+PASS -- testing: foo/bar/baz+xml -- responseXML: undefined
+
+PASS -- testing: foo?bar/baz+xml -- responseXML: undefined
+
+PASS -- testing: foo=bar/baz+xml -- responseXML: undefined
+
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.cgi b/LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.cgi
new file mode 100755 (executable)
index 0000000..cbef3a3
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/perl -w
+
+use CGI qw(:standard);
+my $cgi = new CGI;
+my $type = $cgi->param('type');
+$type =~ s/\^\^PLUS\^\^/+/g;
+
+my $escapedType = $type;
+$escapedType =~ s/&/&#38;/;
+$escapedType =~ s/</&#60;/;
+$escapedType =~ s/>/&#62;/;
+$escapedType =~ s/'/&#39;/;
+$escapedType =~ s/"/&#34;/;
+
+print "Content-type: $type\n\n";
+print "<type>$escapedType</type>\n";
diff --git a/LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.html b/LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.html
new file mode 100644 (file)
index 0000000..b86b766
--- /dev/null
@@ -0,0 +1,88 @@
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+var request = new XMLHttpRequest();
+
+function getXMLOfType(type)
+{
+    var escapedType = escape(type).replace(/\+/g, "^^PLUS^^"); // Perl CGI module seems replace + with a space
+    request.open("GET", "supported-xml-content-types.cgi?type=" + escapedType, false);
+    request.send(null);
+    return request.responseXML;
+}
+
+function testXMLType(type, expected)
+{
+    var xmlResult = getXMLOfType(type);
+    var statusText = "FAIL (response type: " + request.getResponseHeader("Content-type") + ")";
+
+    if (xmlResult) {
+        statusText = "FAIL (got document -- response type: " + request.getResponseHeader("Content-type") + ")";
+        var typeElement = xmlResult.firstChild;
+        if (expected && typeElement) {
+            if (typeElement.textContent == type)
+                statusText = "PASS";
+            else
+                statusText = "FAIL (incorrect content: " + typeElement.textContent + " expected: " + type + ")";
+        }
+    } else if (!expected)
+        statusText = "PASS";
+    
+    document.write("<p>" + statusText + " -- testing: " + type + " -- responseXML: " + xmlResult + "</p>");
+}
+
+// valid types
+testXMLType("text/xml", true);
+testXMLType("image/svg+xml", true);
+testXMLType("application/soap+xml", true);
+testXMLType("foo/bar+xml", true);
+testXMLType("123/BAR+xml", true);
+
+// They may be strange, but these should all be valid:
+testXMLType("foo_bar/baz+xml", true);
+testXMLType("foo-bar/baz+xml", true);
+testXMLType("foo+bar/baz+xml", true);
+testXMLType("foo~bar/baz+xml", true);
+testXMLType("foo!bar/baz+xml", true);
+testXMLType("foo$bar/baz+xml", true);
+testXMLType("foo^bar/baz+xml", true);
+testXMLType("foo{bar/baz+xml", true);
+testXMLType("foo}bar/baz+xml", true);
+testXMLType("foo|bar/baz+xml", true);
+testXMLType("foo%bar/baz+xml", true);
+testXMLType("foo'bar/baz+xml", true);
+testXMLType("foo`bar/baz+xml", true);
+testXMLType("foo#bar/baz+xml", true);
+testXMLType("foo&bar/baz+xml", true);
+testXMLType("foo*bar/baz+xml", true);
+
+// non-xml types
+testXMLType("text/html", false);
+testXMLType("image/png", false);
+
+
+// invalid types
+testXMLType("invalid", false);
+
+// FIXME: our code intentionally skips spaces, that seems wrong to me.
+// http://bugzilla.opendarwin.org/show_bug.cgi?id=8644
+testXMLType("foo bar/baz+xml", false);
+
+testXMLType("foo[bar/baz+xml", false);
+testXMLType("foo]bar/baz+xml", false);
+testXMLType("foo(bar/baz+xml", false);
+testXMLType("foo)bar/baz+xml", false);
+testXMLType("foo<bar/baz+xml", false);
+testXMLType("foo>bar/baz+xml", false);
+testXMLType("foo@bar/baz+xml", false);
+testXMLType("foo,bar/baz+xml", false);
+testXMLType("foo;bar/baz+xml", false);
+testXMLType("foo:bar/baz+xml", false);
+testXMLType("foo\\bar/baz+xml", false);
+testXMLType('foo"bar/baz+xml', false);
+testXMLType("foo/bar/baz+xml", false);
+testXMLType("foo?bar/baz+xml", false);
+testXMLType("foo=bar/baz+xml", false);
+
+</script>
index df2331a553ce05219a0f2c840ca9417c9596cf70..91ddd05dcfaf3406f4688d56aa6ec3619e7cf568 100644 (file)
@@ -1,3 +1,16 @@
+2006-04-27  Eric Seidel  <eseidel@apple.com>
+
+        Reviewed by andersca.
+
+        Make WebCore accept any */*+xml type as XML.
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=5998
+        <rdar://problem/4031511> XmlHttpRequest doesn't allow responses with Content-Type: application/soap+xml
+
+        Test: http/tests/xmlhttprequest/supported-xml-content-types.html
+
+        * dom/DOMImplementation.cpp:
+        (WebCore::DOMImplementation::isXMLMIMEType):
+
 2006-04-27  Eric Seidel  <eseidel@apple.com>
 
         * WebCore.vcproj/WebCore/WebCore.vcproj: Fix break from last checkin.
index 5cade59f1a8d38ef4c096cba01eda22d68b2bd58..6597db50181ce3a2863236f96b4e9d79cc038bc3 100644 (file)
@@ -30,6 +30,7 @@
 #include "ExceptionCode.h"
 #include "css_stylesheetimpl.h"
 #include "HTMLDocument.h"
+#include "RegularExpression.h"
 
 namespace WebCore {
 
@@ -178,12 +179,11 @@ DOMImplementation* DOMImplementation::instance()
 
 bool DOMImplementation::isXMLMIMEType(const String& mimeType)
 {
-    if (mimeType == "text/xml" || mimeType == "application/xml" || mimeType == "application/xhtml+xml" ||
-        mimeType == "text/xsl" || mimeType == "application/rss+xml" || mimeType == "application/atom+xml"
-#if SVG_SUPPORT
-        || mimeType == "image/svg+xml"
-#endif
-        )
+    if (mimeType == "text/xml" || mimeType == "application/xml" || mimeType == "text/xsl")
+        return true;
+    static const char* validChars = "[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]"; // per RFCs: 3023, 2045
+    static RegularExpression xmlTypeRegExp(DeprecatedString("^") + validChars + "+/" + validChars + "+\\+xml$");
+    if (xmlTypeRegExp.match(mimeType.deprecatedString()) > -1)
         return true;
     return false;
 }
index bb356fb80707e9d27a737c31424093b2d37a1b96..d6f2f8fee6eb7b79c763ff40a858d184b5654c34 100644 (file)
@@ -432,7 +432,7 @@ static void setParametersForComponentFunc(CIFilter *filter, const KCComponentTra
         case CT_GAMMA:
             [filter setValue:[NSNumber numberWithFloat:func.amplitude] forKey:@"inputAmplitude"];
             [filter setValue:[NSNumber numberWithFloat:func.exponent] forKey:@"inputExponent"];
-            [filter setValue:[NSNumber numberWithFloat:func.offset] forKey:@"inputOffset"];   
+            [filter setValue:[NSNumber numberWithFloat:func.offset] forKey:@"inputOffset"];
             break;
         default:
             //identity has no args
index 80eea8362c8bca942380d66975a1b6b25008a6e7..8772832751b687804f3d4ac010dba5de30aa9fe2 100644 (file)
@@ -88,7 +88,7 @@ static inline String getMIMEType(const String& contentTypeString)
         QChar c = contentTypeString[offset];
         if (c == ';')
             break;
-        else if (c.isSpace())
+        else if (c.isSpace()) // FIXME: This seems wrong, " " is an invalid MIME type character according to RFC 2045.  bug 8644
             continue;
         mimeType += String(c);
     }