2011-03-16 Pratik Solanki <psolanki@apple.com>
authorpsolanki@apple.com <psolanki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Mar 2011 19:28:55 +0000 (19:28 +0000)
committerpsolanki@apple.com <psolanki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Mar 2011 19:28:55 +0000 (19:28 +0000)
        Reviewed by Alexey Proskuryakov.

        REGRESSION: Crash in adjustMIMETypeIfNecessary since r81001
        https://bugs.webkit.org/show_bug.cgi?id=56345

        Add test that verifies the we don't crash when an XHR response headers don't contain
        Content-Type.

        * http/tests/xmlhttprequest/resources/.htaccess:
        * http/tests/xmlhttprequest/resources/noContentType.asis: Added.
        * http/tests/xmlhttprequest/xmlhttprequest-no-content-type-expected.txt: Added.
        * http/tests/xmlhttprequest/xmlhttprequest-no-content-type.html: Added.
2011-03-16  Pratik Solanki  <psolanki@apple.com>

        Reviewed by Alexey Proskuryakov.

        REGRESSION: Crash in adjustMIMETypeIfNecessary since r81001
        https://bugs.webkit.org/show_bug.cgi?id=56345

        Add NULL check for Content-Type header field.

        Test: http/tests/xmlhttprequest/xmlhttprequest-no-content-type.html

        * platform/network/mac/WebCoreURLResponse.mm:
        (WebCore::adjustMIMETypeIfNecessary):

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

LayoutTests/ChangeLog
LayoutTests/http/tests/xmlhttprequest/resources/.htaccess
LayoutTests/http/tests/xmlhttprequest/resources/noContentType.asis [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-no-content-type-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-no-content-type.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/network/mac/WebCoreURLResponse.mm

index f25cf4d..96fe074 100644 (file)
@@ -1,3 +1,18 @@
+2011-03-16  Pratik Solanki  <psolanki@apple.com>
+
+        Reviewed by Alexey Proskuryakov.
+
+        REGRESSION: Crash in adjustMIMETypeIfNecessary since r81001
+        https://bugs.webkit.org/show_bug.cgi?id=56345
+
+        Add test that verifies the we don't crash when an XHR response headers don't contain
+        Content-Type.
+
+        * http/tests/xmlhttprequest/resources/.htaccess:
+        * http/tests/xmlhttprequest/resources/noContentType.asis: Added.
+        * http/tests/xmlhttprequest/xmlhttprequest-no-content-type-expected.txt: Added.
+        * http/tests/xmlhttprequest/xmlhttprequest-no-content-type.html: Added.
+
 2011-03-16  Levi Weintraub  <leviw@chromium.org>
 
         Reviewed by Ryosuke Niwa.
index a33e4a2..9277940 100644 (file)
@@ -7,3 +7,6 @@ AddCharset koi8-r .txt
 <Files "reply2.xml">
 AddCharset windows-1251 .xml
 </Files>
+<Files "noContentType.asis">
+DefaultType None
+</Files>
diff --git a/LayoutTests/http/tests/xmlhttprequest/resources/noContentType.asis b/LayoutTests/http/tests/xmlhttprequest/resources/noContentType.asis
new file mode 100644 (file)
index 0000000..b66497a
--- /dev/null
@@ -0,0 +1,5 @@
+Connection:keep-alive
+Date:Wed, 16 Mar 2011 05:10:48 GMT
+Server:nginx/0.7.62
+Transfer-Encoding:Identity
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-no-content-type-expected.txt b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-no-content-type-expected.txt
new file mode 100644 (file)
index 0000000..738b849
--- /dev/null
@@ -0,0 +1,3 @@
+Test case for Bug 56345: REGRESSION: Crash in adjustMIMETypeIfNecessary since r81001
+
+This test verifies that an XHR content with no Content-Type set does not crash the browser.
diff --git a/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-no-content-type.html b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-no-content-type.html
new file mode 100644 (file)
index 0000000..1a2b1bd
--- /dev/null
@@ -0,0 +1,26 @@
+<html>
+<head>
+    <title> Test case for bug 56345 </title>
+</head>
+<body>
+<p> Test case for Bug <a href="https://bugs.webkit.org/show_bug.cgi?id=56345">56345</a>: REGRESSION: Crash in adjustMIMETypeIfNecessary since r81001 </p>
+<p> This test verifies that an XHR content with no Content-Type set does not crash the browser. </p>
+<body>
+<script type="text/javascript">
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+function checkDone() {
+    layoutTestController.notifyDone();
+}
+
+var req = new XMLHttpRequest();
+req.onload = checkDone;
+req.open("GET", "resources/noContentType.asis", true);
+req.send(null);
+
+</script>
+</body>
+</html>
index bfc4393..515af2f 100644 (file)
@@ -1,3 +1,17 @@
+2011-03-16  Pratik Solanki  <psolanki@apple.com>
+
+        Reviewed by Alexey Proskuryakov.
+
+        REGRESSION: Crash in adjustMIMETypeIfNecessary since r81001
+        https://bugs.webkit.org/show_bug.cgi?id=56345
+
+        Add NULL check for Content-Type header field.
+
+        Test: http/tests/xmlhttprequest/xmlhttprequest-no-content-type.html
+
+        * platform/network/mac/WebCoreURLResponse.mm:
+        (WebCore::adjustMIMETypeIfNecessary):
+
 2011-03-15  Levi Weintraub  <leviw@chromium.org>
 
         Reviewed by Ryosuke Niwa.
index fb6edf7..0960492 100644 (file)
@@ -522,7 +522,7 @@ void adjustMIMETypeIfNecessary(CFURLResponseRef cfResponse)
         CFHTTPMessageRef message = wkGetCFURLResponseHTTPResponse(cfResponse);
         if (message) {
             RetainPtr<CFStringRef> contentType(AdoptCF, CFHTTPMessageCopyHeaderFieldValue(message, CFSTR("Content-Type")));
-            if (CFStringHasPrefix(contentType.get(), CFSTR("text/plain"))) {
+            if (contentType && CFStringHasPrefix(contentType.get(), CFSTR("text/plain"))) {
                 static CFSetRef binaryExtensions = createBinaryExtensionsSet();
                 RetainPtr<NSString> suggestedFilename(AdoptNS, (NSString *)wkCopyCFURLResponseSuggestedFilename(cfResponse));
                 if (!CFSetContainsValue(binaryExtensions, (CFStringRef) [[suggestedFilename.get() pathExtension] lowercaseString]))