diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/loadlib.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/loadlib.js b/src/loadlib.js index acdf514..da60d0b 100644 --- a/src/loadlib.js +++ b/src/loadlib.js @@ -42,7 +42,15 @@ if (WEB) { xhr.send(); if (xhr.status >= 200 && xhr.status <= 299) { - return eval(xhr.response); + let func; + try { + func = Function(xhr.response); + } catch (e) { + lua.lua_pushstring(L, lua.to_luastring(`${e.name}: ${e.message}`)); + return null; + } + let res = func(); + return res; } else { lua.lua_pushstring(L, lua.to_luastring(`${xhr.status}: ${xhr.statusText}`)); return null; |