From b95b21754fb0ed1725f69985c1fbae4a736e5cfd Mon Sep 17 00:00:00 2001 From: Joao Cardoso Date: Tue, 14 May 2019 19:06:49 +0200 Subject: [PATCH 1/4] 1st attempt at fixing invalid filepaths --- lib/torrent.js | 2 ++ package.json | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/torrent.js b/lib/torrent.js index 8f667ffe..90ecd94a 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -26,6 +26,7 @@ const uniq = require('uniq') const utMetadata = require('ut_metadata') const utPex = require('ut_pex') // browser exclude const parseRange = require('parse-numeric-range') +const filenameReservedRegex = require('filename-reserved-regex') const File = require('./file') const Peer = require('./peer') @@ -447,6 +448,7 @@ class Torrent extends EventEmitter { } this._rarityMap = new RarityMap(this) + this.files.each(file => file.path = file.path.replace(filenameReservedRegex(), '_')) this.store = new ImmediateChunkStore( new this._store(this.pieceLength, { diff --git a/package.json b/package.json index 1f452ed6..580fc4b5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "webtorrent", + "name": "webtorrent-jali", "description": "Streaming torrent client", - "version": "0.103.1", + "version": "0.103.1+1", "author": { "name": "WebTorrent, LLC", "email": "feross@webtorrent.io", @@ -23,7 +23,7 @@ ] }, "bugs": { - "url": "https://github.com/webtorrent/webtorrent/issues" + "url": "https://github.com/Jaliborc/webtorrent/issues" }, "dependencies": { "addr-to-ip-port": "^1.4.2", @@ -34,6 +34,7 @@ "create-torrent": "^3.33.0", "debug": "^4.1.0", "end-of-stream": "^1.1.0", + "filename-reserved-regex": "^2.0.0", "fs-chunk-store": "^1.6.2", "immediate-chunk-store": "^2.0.0", "load-ip-set": "^2.1.0", @@ -107,7 +108,7 @@ "main": "index.js", "repository": { "type": "git", - "url": "git://github.com/webtorrent/webtorrent.git" + "url": "git://github.com/Jaliborc/webtorrent.git" }, "scripts": { "build": "browserify -s WebTorrent -e ./ | minify > webtorrent.min.js", From 2f6ec452f60b365d1a03c467911212fcafd755f5 Mon Sep 17 00:00:00 2001 From: Joao Cardoso Date: Tue, 14 May 2019 21:50:57 +0200 Subject: [PATCH 2/4] Using safe-filename for filepath safe conversion --- lib/torrent.js | 4 ++-- package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/torrent.js b/lib/torrent.js index 90ecd94a..24ac18e7 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -26,7 +26,7 @@ const uniq = require('uniq') const utMetadata = require('ut_metadata') const utPex = require('ut_pex') // browser exclude const parseRange = require('parse-numeric-range') -const filenameReservedRegex = require('filename-reserved-regex') +const safeFilename = require('safe-filename') const File = require('./file') const Peer = require('./peer') @@ -448,7 +448,7 @@ class Torrent extends EventEmitter { } this._rarityMap = new RarityMap(this) - this.files.each(file => file.path = file.path.replace(filenameReservedRegex(), '_')) + this.files.forEach(file => file.path = safeFilename.path(file.path)) this.store = new ImmediateChunkStore( new this._store(this.pieceLength, { diff --git a/package.json b/package.json index 580fc4b5..4bef1b49 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "webtorrent-jali", "description": "Streaming torrent client", - "version": "0.103.1+1", + "version": "0.103.1b", "author": { "name": "WebTorrent, LLC", "email": "feross@webtorrent.io", @@ -34,7 +34,6 @@ "create-torrent": "^3.33.0", "debug": "^4.1.0", "end-of-stream": "^1.1.0", - "filename-reserved-regex": "^2.0.0", "fs-chunk-store": "^1.6.2", "immediate-chunk-store": "^2.0.0", "load-ip-set": "^2.1.0", @@ -53,6 +52,7 @@ "run-parallel": "^1.1.6", "run-parallel-limit": "^1.0.3", "safe-buffer": "^5.0.1", + "safe-filename": "^1.0.1", "simple-concat": "^1.0.0", "simple-get": "^3.0.1", "simple-peer": "^9.0.0", From 128d1afe093680955040bc1c23bc1763632288c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Cardoso?= <442637+Jaliborc@users.noreply.github.com> Date: Thu, 16 May 2019 17:06:30 +0200 Subject: [PATCH 3/4] Update package.json for pull request --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 4bef1b49..ec45c24d 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "webtorrent-jali", + "name": "webtorrent", "description": "Streaming torrent client", "version": "0.103.1b", "author": { @@ -23,7 +23,7 @@ ] }, "bugs": { - "url": "https://github.com/Jaliborc/webtorrent/issues" + "url": "https://github.com/webtorrent/webtorrent/issues" }, "dependencies": { "addr-to-ip-port": "^1.4.2", @@ -108,7 +108,7 @@ "main": "index.js", "repository": { "type": "git", - "url": "git://github.com/Jaliborc/webtorrent.git" + "url": "git://github.com/webtorrent/webtorrent.git" }, "scripts": { "build": "browserify -s WebTorrent -e ./ | minify > webtorrent.min.js", From 7f12ae1b0932a99b62ec6af06e04b6c5a264ebad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Cardoso?= <442637+Jaliborc@users.noreply.github.com> Date: Thu, 16 May 2019 17:07:07 +0200 Subject: [PATCH 4/4] Undo changes to version ID --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ec45c24d..12c310e2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "webtorrent", "description": "Streaming torrent client", - "version": "0.103.1b", + "version": "0.103.1", "author": { "name": "WebTorrent, LLC", "email": "feross@webtorrent.io",