Changeset 160664 in webkit


Ignore:
Timestamp:
Dec 16, 2013 2:51:00 PM (10 years ago)
Author:
andersca@apple.com
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.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r160662 r160664  
     12013-12-16  Anders Carlsson  <andersca@apple.com>
     2
     3        Fix crash when trying to load a null HTML string
     4        https://bugs.webkit.org/show_bug.cgi?id=125801
     5
     6        Reviewed by Dan Bernstein.
     7
     8        * WebProcess/WebPage/WebPage.cpp:
     9        (WebKit::WebPage::loadString):
     10        Check that the string is not null before calling is8Bit(). Also, Use the latin1 encoding for
     11        8-bit strings, since Latin 1 strings are not necessarily valid UTF-8 strings.
     12
    1132013-12-16  Dan Bernstein  <mitz@apple.com>
    214
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r160653 r160664  
    920920void WebPage::loadString(const String& htmlString, const String& MIMEType, const URL& baseURL, const URL& unreachableURL, CoreIPC::MessageDecoder& decoder)
    921921{
    922     if (htmlString.is8Bit()) {
     922    if (!htmlString.isNull() && htmlString.is8Bit()) {
    923923        RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters8()), htmlString.length() * sizeof(LChar));
    924         loadDataImpl(sharedBuffer, MIMEType, ASCIILiteral("utf-8"), baseURL, unreachableURL, decoder);
     924        loadDataImpl(sharedBuffer, MIMEType, ASCIILiteral("latin1"), baseURL, unreachableURL, decoder);
    925925    } else {
    926926        RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters16()), htmlString.length() * sizeof(UChar));
  • trunk/Tools/ChangeLog

    r160655 r160664  
     12013-12-16  Anders Carlsson  <andersca@apple.com>
     2
     3        Fix crash when trying to load a null HTML string
     4        https://bugs.webkit.org/show_bug.cgi?id=125801
     5
     6        Reviewed by Dan Bernstein.
     7
     8        * TestWebKitAPI/Tests/WebKit2/WillLoad.cpp:
     9        (TestWebKitAPI::TEST_F):
     10        Update test results.
     11
    1122013-12-16  Alex Christensen  <achristensen@webkit.org>
    213
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2/WillLoad.cpp

    r160582 r160664  
    180180    WKPageLoadHTMLStringWithUserData(webView->page(), htmlString.get(), baseURL.get(), userData.get());
    181181
    182     testWillLoadDataRequestReturnValues(baseURL.get(), Util::toWK("text/html").get(), Util::toWK("utf-8").get(), 0, userData.get());
     182    testWillLoadDataRequestReturnValues(baseURL.get(), Util::toWK("text/html").get(), Util::toWK("latin1").get(), 0, userData.get());
    183183}
    184184
     
    190190    WKPageLoadHTMLString(webView->page(), htmlString.get(), baseURL.get());
    191191
    192     testWillLoadDataRequestReturnValues(baseURL.get(), Util::toWK("text/html").get(), Util::toWK("utf-8").get(), 0, 0);
     192    testWillLoadDataRequestReturnValues(baseURL.get(), Util::toWK("text/html").get(), Util::toWK("latin1").get(), 0, 0);
    193193}
    194194
     
    203203    WKPageLoadAlternateHTMLStringWithUserData(webView->page(), htmlString.get(), baseURL.get(), unreachableURL.get(), userData.get());
    204204
    205     testWillLoadDataRequestReturnValues(baseURL.get(), Util::toWK("text/html").get(), Util::toWK("utf-8").get(), unreachableURL.get(), userData.get());
     205    testWillLoadDataRequestReturnValues(baseURL.get(), Util::toWK("text/html").get(), Util::toWK("latin1").get(), unreachableURL.get(), userData.get());
    206206}
    207207
     
    215215    WKPageLoadAlternateHTMLString(webView->page(), htmlString.get(), baseURL.get(), unreachableURL.get());
    216216
    217     testWillLoadDataRequestReturnValues(baseURL.get(), Util::toWK("text/html").get(), Util::toWK("utf-8").get(), unreachableURL.get(), 0);
     217    testWillLoadDataRequestReturnValues(baseURL.get(), Util::toWK("text/html").get(), Util::toWK("latin1").get(), unreachableURL.get(), 0);
    218218}
    219219
     
    226226
    227227    WKRetainPtr<WKURLRef> blankURL = adoptWK(WKURLCreateWithUTF8CString("about:blank"));
    228     testWillLoadDataRequestReturnValues(blankURL.get(), Util::toWK("text/plain").get(), Util::toWK("utf-8").get(), 0, userData.get());
     228    testWillLoadDataRequestReturnValues(blankURL.get(), Util::toWK("text/plain").get(), Util::toWK("latin1").get(), 0, userData.get());
    229229}
    230230
     
    236236
    237237    WKRetainPtr<WKURLRef> blankURL = adoptWK(WKURLCreateWithUTF8CString("about:blank"));
    238     testWillLoadDataRequestReturnValues(blankURL.get(), Util::toWK("text/plain").get(), Util::toWK("utf-8").get(), 0, 0);
     238    testWillLoadDataRequestReturnValues(blankURL.get(), Util::toWK("text/plain").get(), Util::toWK("latin1").get(), 0, 0);
    239239}
    240240
Note: See TracChangeset for help on using the changeset viewer.