summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-09-27 23:56:07 +1000
committerdaurnimator <quae@daurnimator.com>2017-09-28 00:02:02 +1000
commit8b42d0503ef37a966f579a4a3f804d6ba3faf2f4 (patch)
treef42e6c7dc49a1c176aa7e1c097dc7bb74dbe957e
parentda1592c025a505eb94ef05a0baa916b829df3b62 (diff)
downloadfengari-8b42d0503ef37a966f579a4a3f804d6ba3faf2f4.tar.gz
fengari-8b42d0503ef37a966f579a4a3f804d6ba3faf2f4.tar.bz2
fengari-8b42d0503ef37a966f579a4a3f804d6ba3faf2f4.zip
src/loadlib.js: escape path before passing to XHR or using as sourceURL
-rw-r--r--src/loadlib.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/loadlib.js b/src/loadlib.js
index 04314b7..d1d5423 100644
--- a/src/loadlib.js
+++ b/src/loadlib.js
@@ -39,6 +39,7 @@ let lsys_load;
if (WEB) {
lsys_load = function(L, path, seeglb) {
path = lua.to_jsstring(path);
+ path = encodeURI(path);
let xhr = new XMLHttpRequest();
xhr.open("GET", path, false);
xhr.send();
@@ -130,10 +131,12 @@ if (!WEB) {
};
} else {
/* TODO: use async/await ? */
- readable = function(filename) {
+ readable = function(path) {
+ path = lua.to_jsstring(path);
+ path = encodeURI(path);
let xhr = new XMLHttpRequest();
/* Following GET request done by searcher_Web will be cached */
- xhr.open("GET", lua.to_jsstring(filename), false);
+ xhr.open("GET", path, false);
xhr.send();
return xhr.status >= 200 && xhr.status <= 299;