]> granicus.if.org Git - apache/commitdiff
fix issue with incorrect munging of the lua package path -- LuaPackagePath directives...
authorBrian McCallister <brianm@apache.org>
Thu, 10 Nov 2011 18:48:50 +0000 (18:48 +0000)
committerBrian McCallister <brianm@apache.org>
Thu, 10 Nov 2011 18:48:50 +0000 (18:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1200475 13f79535-47bb-0310-9956-ffa450edef68

modules/lua/lua_config.c
modules/lua/lua_vmprep.c
modules/lua/mod_lua.c
modules/lua/test/test.lua

index 8a967dc5f2b2bbd78f8242a469cd2faa28a9bd1e..68899a897df46072383d3e63cc234bb2d2765a95 100644 (file)
@@ -155,7 +155,6 @@ static const struct luaL_Reg cfg_methods[] = {
 };
 
 
-
 static int cmd_foo(lua_State *L)
 {
     cmd_parms *cmd = check_cmd_parms(L, 1);
index fb730cfe24bdf65ffe17e62c7377e6b8b1f1f516..65fcd6ffcaf54c2e860e01db0564287f3a35a344 100644 (file)
@@ -245,6 +245,23 @@ static apr_status_t cleanup_lua(void *l)
     return APR_SUCCESS;
 }
 
+/*
+        munge_path(L, 
+                   "path", 
+                   "?.lua", 
+                   "./?.lua", 
+                   lifecycle_pool,
+                   spec->package_paths, 
+                   spec->file);
+*/
+/**
+ * field -> "path" or "cpath"
+ * sub_pat -> "?.lua"
+ * rep_pat -> "./?.lua"
+ * pool -> lifecycle pool for allocations
+ * paths -> things to add
+ * file -> ???
+ */
 static void munge_path(lua_State *L,
                        const char *field,
                        const char *sub_pat,
@@ -261,17 +278,22 @@ static void munge_path(lua_State *L,
 
     lua_getglobal(L, "package");
     lua_getfield(L, -1, field);
+    
     current = lua_tostring(L, -1);
+
     parent_dir = ap_make_dirstr_parent(pool, file);
     pattern = apr_pstrcat(pool, parent_dir, sub_pat, NULL);
     luaL_gsub(L, current, rep_pat, pattern);
     lua_setfield(L, -3, field);
     lua_getfield(L, -2, field);
     modified = lua_tostring(L, -1);
+
+
     lua_pop(L, 2);
 
-    part = apr_pstrcat(pool, modified, apr_array_pstrcat(pool, paths, ';'),
+    part = apr_pstrcat(pool, modified, ";", apr_array_pstrcat(pool, paths, ';'),
                        NULL);
+
     lua_pushstring(L, part);
     lua_setfield(L, -2, field);
     lua_pop(L, 1);              /* pop "package" off the stack     */
@@ -308,8 +330,11 @@ static apr_status_t vm_construct(void **vm, void *params, apr_pool_t *lifecycle_
 #endif
     luaL_openlibs(L);
     if (spec->package_paths) {
-        munge_path(L, "path", "?.lua", "./?.lua", lifecycle_pool,
-            spec->package_paths, spec->file);
+        munge_path(L, 
+                   "path", "?.lua", "./?.lua", 
+                   lifecycle_pool,
+                   spec->package_paths, 
+                   spec->file);
     }
     if (spec->package_cpaths) {
         munge_path(L, "cpath", "?.so", "./?.so", lifecycle_pool,
index a3adf4a5d044b98e1c4c3ab6f6d425ac79326c90..fd55972eafde7bf790b62021b5245ee639960a2b 100644 (file)
@@ -863,16 +863,22 @@ static const char *register_quick_block(cmd_parms *cmd, void *_cfg,
 
 
 
-static const char *register_package_helper(cmd_parms *cmd, const char *arg,
+static const char *register_package_helper(cmd_parms *cmd, 
+                                           const char *arg,
                                            apr_array_header_t *dir_array)
 {
     apr_status_t rv;
 
     ap_lua_server_cfg *server_cfg =
         ap_get_module_config(cmd->server->module_config, &lua_module);
+
     char *fixed_filename;
-    rv = apr_filepath_merge(&fixed_filename, server_cfg->root_path, arg,
-                            APR_FILEPATH_NOTRELATIVE, cmd->pool);
+    rv = apr_filepath_merge(&fixed_filename, 
+                            server_cfg->root_path, 
+                            arg,
+                            APR_FILEPATH_NOTRELATIVE, 
+                            cmd->pool);
+
     if (rv != APR_SUCCESS) {
         return apr_psprintf(cmd->pool,
                             "Unable to build full path to file, %s", arg);
index 59ef00aec8d76b3db93be0c5a1101602c43a9bb3..25da4d9daddbc32dfab34323fdc9191f36c6fbde 100755 (executable)
@@ -18,7 +18,7 @@
 local mu = require "moonunit" 
 local http = require "helpers"
 
-http.base_url = "http://localhost:8000"
+http.base_url = "http://localhost:8008"
 
 local test = mu.TestCase:new{}