From a7d11b2fc032bff3d976a41c95f9ab3846265b58 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 10 May 2020 16:46:21 +0200 Subject: lua: do not use Lua filesystem functions for loading scripts Bill Gates did not only create COVID, he's also responsible for the world's worst OS, where you have to literally jump through hoops of fire to open files with Unicode file names. Lua did not care to implement any jumping, so it's our turn to jump. Untested (on win32). Fixes: #7701 --- player/lua.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/player/lua.c b/player/lua.c index 0b7a1a9489..99402fd2ce 100644 --- a/player/lua.c +++ b/player/lua.c @@ -230,10 +230,13 @@ static void load_file(lua_State *L, const char *fname) { struct script_ctx *ctx = get_ctx(L); MP_DBG(ctx, "loading file %s\n", fname); - int r = luaL_loadfile(L, fname); - if (r) + struct bstr s = stream_read_file(fname, ctx, ctx->mpctx->global, 100000000); + if (!s.start) + luaL_error(L, "Could not read file.\n"); + if (luaL_loadbuffer(L, s.start, s.len, fname)) lua_error(L); - lua_call(L, 0, 0); + lua_call(L, 0, 1); + talloc_free(s.start); } static int load_builtin(lua_State *L) -- cgit v1.2.3