From fb8f0c6d56a945d8c770f3f96336bd21a28e1f42 Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Sat, 2 Apr 2016 12:23:06 +0200 Subject: [PATCH] Unescape pathname from url when loading from local filesystem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a path contains a space it will be escaped to ’%20’. When loading from local filesystem it has to be converted back to a space to get the correct path. --- lib/XMLHttpRequest.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/XMLHttpRequest.js b/lib/XMLHttpRequest.js index 4893913..cd173fd 100644 --- a/lib/XMLHttpRequest.js +++ b/lib/XMLHttpRequest.js @@ -306,7 +306,7 @@ exports.XMLHttpRequest = function() { } if (settings.async) { - fs.readFile(url.pathname, "utf8", function(error, data) { + fs.readFile(unescape(url.pathname), "utf8", function(error, data) { if (error) { self.handleError(error); } else { @@ -317,7 +317,7 @@ exports.XMLHttpRequest = function() { }); } else { try { - this.responseText = fs.readFileSync(url.pathname, "utf8"); + this.responseText = fs.readFileSync(unescape(url.pathname), "utf8"); this.status = 200; setState(self.DONE); } catch(e) {