Changeset 230524 in webkit


Ignore:
Timestamp:
Apr 11, 2018 8:28:37 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Fix a WebRTC data channel issue for non-ASCII characters.

At the sender side, buffer size are calulcated after UTF8 encoding. At the
receiver side, strings are constructed with UTF8 data.

https://bugs.webkit.org/show_bug.cgi?id=184481

Patch by Jianjun Zhu <jianjun.zhu@intel.com> on 2018-04-11
Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

  • web-platform-tests/webrtc/RTCDataChannel-send-expected.txt:

Source/WebCore:

Updated test:
LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDataChannel-send-expected.txt

  • Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:

(WebCore::LibWebRTCDataChannelHandler::sendStringData):
(WebCore::LibWebRTCDataChannelHandler::OnMessage):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r230445 r230524  
     12018-04-11  Jianjun Zhu  <jianjun.zhu@intel.com>
     2
     3        Fix a WebRTC data channel issue for non-ASCII characters.
     4
     5        At the sender side, buffer size are calulcated after UTF8 encoding. At the
     6        receiver side, strings are constructed with UTF8 data.
     7
     8        https://bugs.webkit.org/show_bug.cgi?id=184481
     9
     10        Reviewed by Youenn Fablet.
     11
     12        * web-platform-tests/webrtc/RTCDataChannel-send-expected.txt:
     13
    1142018-04-09  Brendan McLoughlin  <brendan@bocoup.com>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDataChannel-send-expected.txt

    r222307 r230524  
    22PASS Calling send() when data channel is in connecting state should throw InvalidStateError
    33PASS Data channel should be able to send simple string and receive as string
    4 FAIL Data channel should be able to send unicode string and receive as unicode string assert_equals: expected "世界你好" but got "世ç"
     4PASS Data channel should be able to send unicode string and receive as unicode string
    55PASS Data channel should ignore binaryType and always receive string message as string
    66PASS Data channel should be able to send Uint8Array message and receive as ArrayBuffer
  • trunk/Source/WebCore/ChangeLog

    r230522 r230524  
     12018-04-11  Jianjun Zhu  <jianjun.zhu@intel.com>
     2
     3        Fix a WebRTC data channel issue for non-ASCII characters.
     4
     5        At the sender side, buffer size are calulcated after UTF8 encoding. At the
     6        receiver side, strings are constructed with UTF8 data.
     7
     8        https://bugs.webkit.org/show_bug.cgi?id=184481
     9
     10        Reviewed by Youenn Fablet.
     11
     12        Updated test:
     13        LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDataChannel-send-expected.txt
     14
     15        * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:
     16        (WebCore::LibWebRTCDataChannelHandler::sendStringData):
     17        (WebCore::LibWebRTCDataChannelHandler::OnMessage):
     18
    1192018-04-11  Antti Koivisto  <antti@apple.com>
    220
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp

    r215832 r230524  
    4848bool LibWebRTCDataChannelHandler::sendStringData(const String& text)
    4949{
    50     return m_channel->Send({rtc::CopyOnWriteBuffer(text.utf8().data(), text.length()), false});
     50    auto utf8Text = text.utf8();
     51    return m_channel->Send({ rtc::CopyOnWriteBuffer(utf8Text.data(), utf8Text.length()), false });
    5152}
    5253
     
    9798    std::unique_ptr<webrtc::DataBuffer> protectedBuffer(new webrtc::DataBuffer(buffer));
    9899    callOnMainThread([protectedClient = makeRef(*m_client), buffer = WTFMove(protectedBuffer)] {
    99         // FIXME: Ensure this is correct by adding some tests with non-ASCII characters.
    100         const char* data = reinterpret_cast<const char*>(buffer->data.data());
     100        const char* data = reinterpret_cast<const char*>(buffer->data.data<char>());
    101101        if (buffer->binary)
    102102            protectedClient->didReceiveRawData(data, buffer->size());
    103103        else
    104             protectedClient->didReceiveStringData(String(data, buffer->size()));
     104            protectedClient->didReceiveStringData(String::fromUTF8(data, buffer->size()));
    105105    });
    106106}
Note: See TracChangeset for help on using the changeset viewer.