From 0c0754b897f62a68d7da3600f96924fab54e4f8f Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Fri, 14 Jan 2022 15:26:07 +0100 Subject: [PATCH] [fix] Use the byte length of the data (#2004) Ensure that the correct length is used when framing the data. --- lib/sender.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/sender.js b/lib/sender.js index d331f653a..c84885362 100644 --- a/lib/sender.js +++ b/lib/sender.js @@ -103,10 +103,10 @@ class Sender { let payloadLength = dataLength; - if (data.length >= 65536) { + if (dataLength >= 65536) { offset += 8; payloadLength = 127; - } else if (data.length > 125) { + } else if (dataLength > 125) { offset += 2; payloadLength = 126; } @@ -136,11 +136,11 @@ class Sender { if (skipMasking) return [target, data]; if (merge) { - applyMask(data, mask, target, offset, data.length); + applyMask(data, mask, target, offset, dataLength); return [target]; } - applyMask(data, mask, data, 0, data.length); + applyMask(data, mask, data, 0, dataLength); return [target, data]; }