Title: [265939] trunk/Source/WebKit
Revision
265939
Author
you...@apple.com
Date
2020-08-20 03:43:38 -0700 (Thu, 20 Aug 2020)

Log Message

WebSocketTask::close should correctly compute reason byte size in UTF-8
https://bugs.webkit.org/show_bug.cgi?id=215645

Reviewed by Darin Adler.

Covered by http/tests/websocket/tests/hybi/close.html with NSURLSession code path enabled.

* NetworkProcess/cocoa/WebSocketTaskCocoa.mm:
(WebKit::WebSocketTask::close):
Instead of calling sizeInBytes, we should just get the utf8 CString and gets its size directly.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (265938 => 265939)


--- trunk/Source/WebKit/ChangeLog	2020-08-20 07:15:06 UTC (rev 265938)
+++ trunk/Source/WebKit/ChangeLog	2020-08-20 10:43:38 UTC (rev 265939)
@@ -1,3 +1,16 @@
+2020-08-20  Youenn Fablet  <you...@apple.com>
+
+        WebSocketTask::close should correctly compute reason byte size in UTF-8
+        https://bugs.webkit.org/show_bug.cgi?id=215645
+
+        Reviewed by Darin Adler.
+
+        Covered by http/tests/websocket/tests/hybi/close.html with NSURLSession code path enabled.
+
+        * NetworkProcess/cocoa/WebSocketTaskCocoa.mm:
+        (WebKit::WebSocketTask::close):
+        Instead of calling sizeInBytes, we should just get the utf8 CString and gets its size directly.
+
 2020-08-19  Fujii Hironori  <hironori.fu...@sony.com>
 
         IPC message can't be decoded due to uninitialized NavigationActionData member variables with the latest MSVC

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.mm (265938 => 265939)


--- trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.mm	2020-08-20 07:15:06 UTC (rev 265938)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.mm	2020-08-20 10:43:38 UTC (rev 265939)
@@ -137,7 +137,8 @@
     // FIXME: Should NSURLSession provide a way to call cancelWithCloseCode without any specific code.
     if (code == WebCore::WebSocketChannel::CloseEventCodeNotSpecified)
         code = 1005;
-    auto nsData = adoptNS([[NSData alloc] initWithBytes:reason.utf8().data() length:reason.sizeInBytes()]);
+    auto utf8 = reason.utf8();
+    auto nsData = adoptNS([[NSData alloc] initWithBytes:utf8.data() length:utf8.length()]);
     [m_task cancelWithCloseCode:(NSURLSessionWebSocketCloseCode)code reason:nsData.get()];
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to