Explorar o código

Lua: use document_root if websocket_root is not set

bel %!s(int64=8) %!d(string=hai) anos
pai
achega
27774f0fe2
Modificáronse 1 ficheiros con 7 adicións e 2 borrados
  1. 7 2
      src/mod_lua.inl

+ 7 - 2
src/mod_lua.inl

@@ -65,7 +65,8 @@ reg_lstring(struct lua_State *L,
 	}
 }
 
-#define reg_string(L, name, val) reg_lstring(L, name, val, strlen(val))
+#define reg_string(L, name, val)                                               \
+	reg_lstring(L, name, val, val ? strlen(val) : 0)
 
 static void
 reg_int(struct lua_State *L, const char *name, int val)
@@ -1436,7 +1437,11 @@ prepare_lua_environment(struct mg_context *ctx,
 		reg_string(L, "document_root", ctx->config[DOCUMENT_ROOT]);
 		reg_string(L, "auth_domain", ctx->config[AUTHENTICATION_DOMAIN]);
 #if defined(USE_WEBSOCKET)
-		reg_string(L, "websocket_root", ctx->config[WEBSOCKET_ROOT]);
+		if (ctx->config[WEBSOCKET_ROOT]) {
+			reg_string(L, "websocket_root", ctx->config[WEBSOCKET_ROOT]);
+		} else {
+			reg_string(L, "websocket_root", ctx->config[DOCUMENT_ROOT]);
+		}
 #endif
 
 		if (ctx->systemName != NULL) {