Title: [230524] trunk
Revision
230524
Author
commit-qu...@webkit.org
Date
2018-04-11 08:28:37 -0700 (Wed, 11 Apr 2018)

Log 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....@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):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (230523 => 230524)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2018-04-11 14:29:39 UTC (rev 230523)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2018-04-11 15:28:37 UTC (rev 230524)
@@ -1,3 +1,16 @@
+2018-04-11  Jianjun Zhu  <jianjun....@intel.com>
+
+        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
+
+        Reviewed by Youenn Fablet.
+
+        * web-platform-tests/webrtc/RTCDataChannel-send-expected.txt:
+
 2018-04-09  Brendan McLoughlin  <bren...@bocoup.com>
 
         sync remaining web-platform-tests to 94b33b573a069ae5170104ca581a354a35762536

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDataChannel-send-expected.txt (230523 => 230524)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDataChannel-send-expected.txt	2018-04-11 14:29:39 UTC (rev 230523)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDataChannel-send-expected.txt	2018-04-11 15:28:37 UTC (rev 230524)
@@ -1,7 +1,7 @@
 
 PASS Calling send() when data channel is in connecting state should throw InvalidStateError 
 PASS Data channel should be able to send simple string and receive as string 
-FAIL Data channel should be able to send unicode string and receive as unicode string assert_equals: expected "世界你好" but got "世ç"
+PASS Data channel should be able to send unicode string and receive as unicode string 
 PASS Data channel should ignore binaryType and always receive string message as string 
 PASS Data channel should be able to send Uint8Array message and receive as ArrayBuffer 
 PASS Data channel should be able to send ArrayBuffer message and receive as ArrayBuffer 

Modified: trunk/Source/WebCore/ChangeLog (230523 => 230524)


--- trunk/Source/WebCore/ChangeLog	2018-04-11 14:29:39 UTC (rev 230523)
+++ trunk/Source/WebCore/ChangeLog	2018-04-11 15:28:37 UTC (rev 230524)
@@ -1,3 +1,21 @@
+2018-04-11  Jianjun Zhu  <jianjun....@intel.com>
+
+        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
+
+        Reviewed by Youenn Fablet.
+
+        Updated test:
+        LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDataChannel-send-expected.txt
+
+        * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:
+        (WebCore::LibWebRTCDataChannelHandler::sendStringData):
+        (WebCore::LibWebRTCDataChannelHandler::OnMessage):
+
 2018-04-11  Antti Koivisto  <an...@apple.com>
 
         ImageFrame type used by non-Cocoa image decoder should not be the same as that used by ImageSource

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp (230523 => 230524)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp	2018-04-11 14:29:39 UTC (rev 230523)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp	2018-04-11 15:28:37 UTC (rev 230524)
@@ -47,7 +47,8 @@
 
 bool LibWebRTCDataChannelHandler::sendStringData(const String& text)
 {
-    return m_channel->Send({rtc::CopyOnWriteBuffer(text.utf8().data(), text.length()), false});
+    auto utf8Text = text.utf8();
+    return m_channel->Send({ rtc::CopyOnWriteBuffer(utf8Text.data(), utf8Text.length()), false });
 }
 
 bool LibWebRTCDataChannelHandler::sendRawData(const char* data, size_t length)
@@ -96,12 +97,11 @@
 
     std::unique_ptr<webrtc::DataBuffer> protectedBuffer(new webrtc::DataBuffer(buffer));
     callOnMainThread([protectedClient = makeRef(*m_client), buffer = WTFMove(protectedBuffer)] {
-        // FIXME: Ensure this is correct by adding some tests with non-ASCII characters.
-        const char* data = "" char*>(buffer->data.data());
+        const char* data = "" char*>(buffer->data.data<char>());
         if (buffer->binary)
             protectedClient->didReceiveRawData(data, buffer->size());
         else
-            protectedClient->didReceiveStringData(String(data, buffer->size()));
+            protectedClient->didReceiveStringData(String::fromUTF8(data, buffer->size()));
     });
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to