diff options
author | wm4 <wm4@nowhere> | 2020-05-10 16:46:21 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-05-10 17:00:07 +0200 |
commit | a7d11b2fc032bff3d976a41c95f9ab3846265b58 (patch) | |
tree | 45565cb5b5db64b80cca4d68af50534f5b85a396 | |
parent | ad9f3bfe961b3f3bf3e047316419a60de8be49e7 (diff) | |
download | mpv-a7d11b2fc032bff3d976a41c95f9ab3846265b58.tar.bz2 mpv-a7d11b2fc032bff3d976a41c95f9ab3846265b58.tar.xz |
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
-rw-r--r-- | player/lua.c | 9 |
1 files 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) |