From 8b42d0503ef37a966f579a4a3f804d6ba3faf2f4 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Wed, 27 Sep 2017 23:56:07 +1000 Subject: src/loadlib.js: escape path before passing to XHR or using as sourceURL --- src/loadlib.js | 7 +++++-- 1 file 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; -- cgit v1.2.3-70-g09d2