Commit Graph

46 Commits

Author SHA1 Message Date
Damien Arrachequesne
d848f0fc82 [refactor] Remove any reference to the global variable (#103)
Related #99
2018-10-31 06:23:32 +01:00
Damien Arrachequesne
3bc16f5938 [refactor] Remove custom exports from utf8.js file (#102)
AMD and browser exports are useless here.
2018-10-31 06:23:08 +01:00
Damien Arrachequesne
bffb63ebfa [revert] "[fix] Enable to utf8-decode string payloads (#88)" (#91)
This reverts commit 278a7e45e7.
2017-04-24 13:53:17 +02:00
Damien Arrachequesne
528345470c [chore] Use has-binary2 (#90) 2017-04-05 23:17:20 +02:00
Damien Arrachequesne
278a7e45e7 [fix] Enable to utf8-decode string payloads (#88)
That will allow clients receiving the xhr payload with
responseType = 'arraybuffer' to properly decode the message, which is
not sent as binary by the backend anymore since 292c00c (#85).
2017-03-21 14:35:00 +01:00
Damien Arrachequesne
292c00c183 [fix] Encode string payloads as strings even if binary supported (#85)
This reverts commit 44c7aa5, which caused string payloads to be encoded
as binary (so that huge string payloads were needlessly UTF-8-encoded).

Related: https://github.com/socketio/socket.io/issues/2872
2017-03-06 12:24:11 +01:00
Gatsbill
89a465a4b8 [perf] Micro optimisations (#84) 2016-12-23 07:19:13 +01:00
Damien Arrachequesne
d1c2680ca9 [fix] Sanitize strings by removing lone surrogates (#82) 2016-12-21 22:01:19 +01:00
Billouboq
2d83f9da17 [perf] Use strict equality where possible (#77) 2016-12-21 09:52:23 +01:00
Damien Arrachequesne
ebf92a5097 [style] Minor style changes (#83) 2016-12-21 09:31:14 +01:00
Damien Arrachequesne
181acef657 [fix] Fix double utf8 encoding for payloads (#81) 2016-12-21 09:15:07 +01:00
Damien Arrachequesne
6741900f37 [fix] Handle undefined case properly when decoding packet (#74) 2016-10-20 14:39:04 +02:00
jm
5aecaa914d [fix] decodePacket now accepts both Buffer and ArrayBuffer as data
Closes #64, fixes #60
2016-10-20 14:17:02 +02:00
Jack X
4a818a0ed7 [fix] Add safety check for global object
Closes #71
2016-10-18 01:40:29 +02:00
Damien Arrachequesne
f5d966bd66 [chore] Use wtf-8 instead of utf8 to prevent lone surrogates from generating parsing error (#68) 2016-09-26 03:44:29 +02:00
Tom Atkinson
26162afe01 [perf] Split try catch into separate function (#65) 2016-09-26 03:40:17 +02:00
Theodore Ni
c0d166b861 Require base64-arraybuffer module conditionally.
Since base64-arraybuffer version 0.1.5 introduced a change that fails
at require time in a browser without ArrayBuffer support, the require
must be guarded.
2016-06-25 22:12:44 -07:00
Dana Woodman
748144b50a Ensure navigator is defined. 2016-03-09 12:34:38 -08:00
Dana Woodman
a10c487518 Fix crash in React Native
This change lets people use Socket.io in React Native

Related to an issue on socket.io-client repo: https://github.com/socketio/socket.io-client/issues/945

All credit for this goes to @stevecass
2016-03-09 12:28:48 -08:00
Damien Arrachequesne
96fa4f907a Fix ArrayBuffer encoding in base64 string 2015-12-02 10:49:33 +01:00
nkzawa
685cb719e8 fix encoding blob as base64 2015-11-22 16:05:26 +09:00
Tom Atkinson
664f2af8e7 Fix some additional test failures found in main engine.io test suite 2015-08-22 04:07:37 +02:00
Tom Atkinson
32980f8f63 Fix iojs 3.0 Buffer.buffer issue 2015-08-20 23:46:46 +02:00
Tony Kovanen
b21717b66d Pass has-binary result to encodePacket
Needs to be done so thet individual packets don't get encoded as binary.
2015-01-16 21:28:01 +02:00
Tony Kovanen
44c7aa5ab9 Fix parse error
We always need to send binary when encoding payloads when sending from
server to client, because the polling transport has to know the response
type ahead of time.
2015-01-16 21:19:27 +02:00
Guillermo Rauch
e53e9f5931 Merge pull request #36 from cvlchinet/patch
Allow sending binary data without ArrayBuffer (e. g. IE8)
2014-12-10 17:57:26 -03:00
Tony Kovanen
68d89ab7a9 encode into binary only if needed 2014-12-03 02:07:10 +02:00
Chi Vinh Le
2c1beccbb1 Add line space. 2014-11-20 23:49:46 +01:00
Chi Vinh Le
7112b97908 Add encodeBase64Object to encoder for browser 2014-11-20 13:49:46 +01:00
ddivernois
d2e1e94ef5 Avoid sending Blobs on PhantomJS (as on Android)
Uploading a Blob with PhantomJS does not work correctly, as reported here:
https://github.com/ariya/phantomjs/issues/11395
2014-10-06 11:13:11 +02:00
Tony Kovanen
95840ca6b6 Don't UTF-8 encode packets unless asked.
Still done in payload encoding for polling, but no need with WebSockets since it deals with UTF-8 itself.
2014-07-17 00:54:00 +03:00
Guillermo Rauch
1e26a69e4f adjust protocol revision. fixes #30 2014-07-12 21:01:22 -07:00
Naoyuki Kanezawa
4dc1a13750 handle invalid utf8 errors gracefully 2014-06-29 18:22:53 +09:00
Tony Kovanen
0cec2433b2 Fix memory leak on browser
Will exit with an error packet if the packet length string doesn't contain the value 255 in binary packets.
2014-06-25 06:32:05 +03:00
Guillermo Rauch
ca02f2bfad add comment per @christophwitzko 2014-06-24 15:20:18 -07:00
Christoph Witzko
d41f8e06da fix decodePayloadAsBinary memory leak 2014-06-24 23:49:57 +02:00
Tony Kovanen
2da2fbbabc Don't use the already deprecated binary buffer encoding 2014-05-30 16:04:38 +03:00
Tony Kovanen
067e286d2b Use plain binary encoding for byte length since we're now using utf8.js 2014-05-30 14:15:27 +03:00
Joey Baker
b0e75f94c4 Don't pass too many arguments
`.apply()` has a max argument length which was easily exceeded by a large buffer. This makes more calls to `String.fromCharCode` but is guaranteed not to throw a `RangeError`.

More on max argument size: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply#Using_apply_and_built-in_functions
2014-05-05 15:02:08 -07:00
Tony Kovanen
52bc2f8c03 Encode strings with utf8.js to support multibyte strings 2014-04-30 01:23:35 +03:00
Naoyuki Kanezawa
14728f9a77 fix encodePayloadAsBinary method encodes packets to base64 2014-04-02 00:41:40 +09:00
binlain
395ff6f86f Fix length calculation when encoding as binary 2014-03-26 00:11:02 +01:00
Tony Kovanen
112c37966b Encoding binary as ArrayBuffer for android, because blob data is sent as empty payload 2014-03-16 14:28:04 +02:00
Tony Kovanen
ec08d1d004 Using the blob module for creating a blob constructor that abstracts the constructor api used 2014-03-07 00:35:46 +02:00
Tony Kovanen
56e1ce292d Style, bump arraybuffer.slice version and remove nbsp 2014-03-06 22:49:24 +02:00
Guillermo Rauch
105fb8befe moving code from engine.io-protocol 2014-02-18 13:06:06 -08:00