From b600ba0123b8af27d2d25e7655b311163afaec91 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Fri, 5 May 2017 10:33:23 +1000 Subject: Fix luaL_error callsites - Now that luaL_error does sprintf-like formatting it shouldn't take user input - % now needs to be escaped when passed to luaL_error - Removes several wasteful lua->js->lua string transformations --- src/liolib.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/liolib.js') diff --git a/src/liolib.js b/src/liolib.js index 2136755..1557adf 100644 --- a/src/liolib.js +++ b/src/liolib.js @@ -31,7 +31,7 @@ const f_tostring = function(L) { const tofile = function(L) { let p = tolstream(L); if (isclosed(p)) - lauxlib.luaL_error(L, "attempt to use a closed file"); + lauxlib.luaL_error(L, lua.to_luastring("attempt to use a closed file")); assert(p.f); return p.f; }; @@ -62,7 +62,7 @@ const getiofile = function(L, findex) { lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, findex); let p = lua.lua_touserdata(L, -1); if (isclosed(p)) - lauxlib.luaL_error(L, lua.to_luastring(`standard ${lua.to_jsstring(findex.slice(IOPREF_LEN))} file is closed`)); + lauxlib.luaL_error(L, lua.to_luastring("standard %s file is closed"), findex.slice(IOPREF_LEN)); return p.f; }; -- cgit v1.2.3-54-g00ecf