From e4c09c7cba9cb21db447e1e8d00051e97b40f7d8 Mon Sep 17 00:00:00 2001 From: Mukul Mishra Date: Tue, 19 Sep 2017 15:10:36 +0530 Subject: [PATCH] Fix #8907: Decode URL to get correct path in node_stream. --- src/display/node_stream.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/display/node_stream.js b/src/display/node_stream.js index 443989363..f8b1079a6 100644 --- a/src/display/node_stream.js +++ b/src/display/node_stream.js @@ -360,8 +360,9 @@ class PDFNodeStreamRangeReader extends BaseRangeReader { class PDFNodeStreamFsFullReader extends BaseFullReader { constructor(stream) { super(stream); + let path = decodeURI(this._url.path); - fs.lstat(this._url.path, (error, stat) => { + fs.lstat(path, (error, stat) => { if (error) { this._errored = true; this._reason = error; @@ -371,7 +372,7 @@ class PDFNodeStreamFsFullReader extends BaseFullReader { // Setting right content length. this._contentLength = stat.size; - this._setReadableStream(fs.createReadStream(this._url.path)); + this._setReadableStream(fs.createReadStream(path)); this._headersCapability.resolve(); }); } @@ -382,7 +383,7 @@ class PDFNodeStreamFsRangeReader extends BaseRangeReader { super(stream); this._setReadableStream( - fs.createReadStream(this._url.path, { start, end: end - 1, })); + fs.createReadStream(decodeURI(this._url.path), { start, end: end - 1, })); } }