Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Unified Diff: sdk/lib/io/websocket_impl.dart

Issue 16363005: Ensure that only byte values are sent by sockets and web sockets (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/io/websocket_impl.dart
diff --git a/sdk/lib/io/websocket_impl.dart b/sdk/lib/io/websocket_impl.dart
index 810808444560813d0015c896a5f72fc35a577786..b59c7758968a1783b9e63f7c18356bdeeca6dca3 100644
--- a/sdk/lib/io/websocket_impl.dart
+++ b/sdk/lib/io/websocket_impl.dart
@@ -532,8 +532,17 @@ class _WebSocketOutgoingTransformer extends StreamEventTransformer {
index += 4;
if (data != null) {
var list = new Uint8List(data.length);
Anders Johnsen 2013/06/12 06:13:58 If we check if it's a string here, we could just a
Søren Gjesse 2013/06/12 08:34:00 Good point. Done.
- for (int i = 0; i < data.length; i++) {
- list[i] = data[i] ^ maskBytes[i % 4];
+ if (data is Uint8List) {
+ for (int i = 0; i < data.length; i++) {
+ list[i] = data[i] ^ maskBytes[i % 4];
+ }
+ } else {
+ for (int i = 0; i < data.length; i++) {
+ if (data[i] < 0 || 255 < data[0]) {
Anders Johnsen 2013/06/12 06:13:58 This reads odd, as you have two '<'. Also, second
Søren Gjesse 2013/06/12 08:34:00 This reads nicely :-) data[i] is outside the inter
+ throw new ArgumentError("Illegal byte value ${data[0]}");
+ }
+ list[i] = data[i] ^ maskBytes[i % 4];
+ }
}
data = list;
}

Powered by Google App Engine
This is Rietveld 408576698