Title: [160664] trunk
Revision
160664
Author
[email protected]
Date
2013-12-16 14:51:00 -0800 (Mon, 16 Dec 2013)

Log Message

Fix crash when trying to load a null HTML string
https://bugs.webkit.org/show_bug.cgi?id=125801

Reviewed by Dan Bernstein.

Source/WebKit2:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::loadString):
Check that the string is not null before calling is8Bit(). Also, Use the latin1 encoding for
8-bit strings, since Latin 1 strings are not necessarily valid UTF-8 strings.

Tools:

* TestWebKitAPI/Tests/WebKit2/WillLoad.cpp:
(TestWebKitAPI::TEST_F):
Update test results.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (160663 => 160664)


--- trunk/Source/WebKit2/ChangeLog	2013-12-16 22:41:56 UTC (rev 160663)
+++ trunk/Source/WebKit2/ChangeLog	2013-12-16 22:51:00 UTC (rev 160664)
@@ -1,3 +1,15 @@
+2013-12-16  Anders Carlsson  <[email protected]>
+
+        Fix crash when trying to load a null HTML string
+        https://bugs.webkit.org/show_bug.cgi?id=125801
+
+        Reviewed by Dan Bernstein.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::loadString):
+        Check that the string is not null before calling is8Bit(). Also, Use the latin1 encoding for
+        8-bit strings, since Latin 1 strings are not necessarily valid UTF-8 strings.
+
 2013-12-16  Dan Bernstein  <[email protected]>
 
         [Cocoa] Expose whether the page contains only secure content

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (160663 => 160664)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-12-16 22:41:56 UTC (rev 160663)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-12-16 22:51:00 UTC (rev 160664)
@@ -919,9 +919,9 @@
 
 void WebPage::loadString(const String& htmlString, const String& MIMEType, const URL& baseURL, const URL& unreachableURL, CoreIPC::MessageDecoder& decoder)
 {
-    if (htmlString.is8Bit()) {
+    if (!htmlString.isNull() && htmlString.is8Bit()) {
         RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters8()), htmlString.length() * sizeof(LChar));
-        loadDataImpl(sharedBuffer, MIMEType, ASCIILiteral("utf-8"), baseURL, unreachableURL, decoder);
+        loadDataImpl(sharedBuffer, MIMEType, ASCIILiteral("latin1"), baseURL, unreachableURL, decoder);
     } else {
         RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters16()), htmlString.length() * sizeof(UChar));
         loadDataImpl(sharedBuffer, MIMEType, ASCIILiteral("utf-16"), baseURL, unreachableURL, decoder);

Modified: trunk/Tools/ChangeLog (160663 => 160664)


--- trunk/Tools/ChangeLog	2013-12-16 22:41:56 UTC (rev 160663)
+++ trunk/Tools/ChangeLog	2013-12-16 22:51:00 UTC (rev 160664)
@@ -1,3 +1,14 @@
+2013-12-16  Anders Carlsson  <[email protected]>
+
+        Fix crash when trying to load a null HTML string
+        https://bugs.webkit.org/show_bug.cgi?id=125801
+
+        Reviewed by Dan Bernstein.
+
+        * TestWebKitAPI/Tests/WebKit2/WillLoad.cpp:
+        (TestWebKitAPI::TEST_F):
+        Update test results.
+
 2013-12-16  Alex Christensen  <[email protected]>
 
         Fixed Win64 build on VS2013.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2/WillLoad.cpp (160663 => 160664)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/WillLoad.cpp	2013-12-16 22:41:56 UTC (rev 160663)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/WillLoad.cpp	2013-12-16 22:51:00 UTC (rev 160664)
@@ -179,7 +179,7 @@
 
     WKPageLoadHTMLStringWithUserData(webView->page(), htmlString.get(), baseURL.get(), userData.get());
 
-    testWillLoadDataRequestReturnValues(baseURL.get(), Util::toWK("text/html").get(), Util::toWK("utf-8").get(), 0, userData.get());
+    testWillLoadDataRequestReturnValues(baseURL.get(), Util::toWK("text/html").get(), Util::toWK("latin1").get(), 0, userData.get());
 }
 
 TEST_F(WebKit2WillLoadTest, WKPageLoadHTMLString)
@@ -189,7 +189,7 @@
 
     WKPageLoadHTMLString(webView->page(), htmlString.get(), baseURL.get());
 
-    testWillLoadDataRequestReturnValues(baseURL.get(), Util::toWK("text/html").get(), Util::toWK("utf-8").get(), 0, 0);
+    testWillLoadDataRequestReturnValues(baseURL.get(), Util::toWK("text/html").get(), Util::toWK("latin1").get(), 0, 0);
 }
 
 TEST_F(WebKit2WillLoadTest, WKPageLoadAlternateHTMLStringWithUserData)
@@ -202,7 +202,7 @@
 
     WKPageLoadAlternateHTMLStringWithUserData(webView->page(), htmlString.get(), baseURL.get(), unreachableURL.get(), userData.get());
 
-    testWillLoadDataRequestReturnValues(baseURL.get(), Util::toWK("text/html").get(), Util::toWK("utf-8").get(), unreachableURL.get(), userData.get());
+    testWillLoadDataRequestReturnValues(baseURL.get(), Util::toWK("text/html").get(), Util::toWK("latin1").get(), unreachableURL.get(), userData.get());
 }
 
 TEST_F(WebKit2WillLoadTest, WKPageLoadAlternateHTMLString)
@@ -214,7 +214,7 @@
 
     WKPageLoadAlternateHTMLString(webView->page(), htmlString.get(), baseURL.get(), unreachableURL.get());
 
-    testWillLoadDataRequestReturnValues(baseURL.get(), Util::toWK("text/html").get(), Util::toWK("utf-8").get(), unreachableURL.get(), 0);
+    testWillLoadDataRequestReturnValues(baseURL.get(), Util::toWK("text/html").get(), Util::toWK("latin1").get(), unreachableURL.get(), 0);
 }
 
 TEST_F(WebKit2WillLoadTest, WKPageLoadPlainTextStringWithUserData)
@@ -225,7 +225,7 @@
     WKPageLoadPlainTextStringWithUserData(webView->page(), plaintTextString.get(), userData.get());
 
     WKRetainPtr<WKURLRef> blankURL = adoptWK(WKURLCreateWithUTF8CString("about:blank"));
-    testWillLoadDataRequestReturnValues(blankURL.get(), Util::toWK("text/plain").get(), Util::toWK("utf-8").get(), 0, userData.get());
+    testWillLoadDataRequestReturnValues(blankURL.get(), Util::toWK("text/plain").get(), Util::toWK("latin1").get(), 0, userData.get());
 }
 
 TEST_F(WebKit2WillLoadTest, WKPageLoadPlainTextString)
@@ -235,7 +235,7 @@
     WKPageLoadPlainTextString(webView->page(), plaintTextString.get());
 
     WKRetainPtr<WKURLRef> blankURL = adoptWK(WKURLCreateWithUTF8CString("about:blank"));
-    testWillLoadDataRequestReturnValues(blankURL.get(), Util::toWK("text/plain").get(), Util::toWK("utf-8").get(), 0, 0);
+    testWillLoadDataRequestReturnValues(blankURL.get(), Util::toWK("text/plain").get(), Util::toWK("latin1").get(), 0, 0);
 }
 
 } // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to