Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2016-05-30 08:50:40 +0300
committerFeross Aboukhadijeh <feross@feross.org>2016-05-30 08:50:40 +0300
commit69227bd5899294d43b9bee0f5a075a8190b1af75 (patch)
tree1bf6f42ee64c9b0e1c86862422ef7764e91599eb /test/client-add.js
parent7fb250f6767796bdc88f9a1d4536dbc6c731e465 (diff)
Use safe-buffer
Use the new Buffer APIs from Node v6 for added security. For example, Buffer.from() will throw if passed a number, unlike Buffer() which allocated UNINITIALIZED memory. Use the safe-buffer package for compatibility with previous versions of Node.js, including v4.x, v0.12, and v0.10. https://github.com/feross/safe-buffer
Diffstat (limited to 'test/client-add.js')
-rw-r--r--test/client-add.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/test/client-add.js b/test/client-add.js
index d30fea0..a3a18cd 100644
--- a/test/client-add.js
+++ b/test/client-add.js
@@ -1,3 +1,4 @@
+var Buffer = require('safe-buffer').Buffer
var extend = require('xtend')
var fixtures = require('webtorrent-fixtures')
var test = require('tape')
@@ -84,7 +85,7 @@ test('client.add: info hash, buffer', function (t) {
t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
t.ok(torrent.magnetURI.indexOf('magnet:?xt=urn:btih:' + fixtures.leaves.parsedTorrent.infoHash) === 0)
- client.remove(new Buffer(fixtures.leaves.parsedTorrent.infoHash, 'hex'), function (err) { t.error(err, 'torrent destroyed') })
+ client.remove(Buffer.from(fixtures.leaves.parsedTorrent.infoHash, 'hex'), function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
client.destroy(function (err) { t.error(err, 'client destroyed') })
@@ -204,5 +205,5 @@ test('client.add: invalid torrent id: short buffer', function (t) {
})
client.on('warning', function (err) { t.fail(err) })
- client.add(new Buffer('abc'))
+ client.add(Buffer.from('abc'))
})