From 5647f0bf9e064c616d7ca8dd8cab2db454c453c3 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Tue, 2 Feb 2021 17:56:42 +0200 Subject: [PATCH] wplua: allow loading relative paths from wplua_load_path() convert them to absolute before creating the URI --- lib/wplua/wplua.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/wplua/wplua.c b/lib/wplua/wplua.c index cdbc02ba..0a186a9b 100644 --- a/lib/wplua/wplua.c +++ b/lib/wplua/wplua.c @@ -249,12 +249,18 @@ wplua_load_uri (lua_State * L, const gchar *uri, GError **error) gboolean wplua_load_path (lua_State * L, const gchar *path, GError **error) { + g_autofree gchar *abs_path = NULL; g_autofree gchar *uri = NULL; g_return_val_if_fail (L != NULL, FALSE); g_return_val_if_fail (path != NULL, FALSE); - if (!(uri = g_filename_to_uri (path, NULL, error))) + if (!g_path_is_absolute (path)) { + g_autofree gchar *cwd = g_get_current_dir (); + abs_path = g_build_filename (cwd, path, NULL); + } + + if (!(uri = g_filename_to_uri (abs_path ? abs_path : path, NULL, error))) return FALSE; return wplua_load_uri (L, uri, error);