fix cli unit document root resolution

This commit is contained in:
udo 2026-07-06 20:35:09 +00:00
parent 6f446c4aef
commit 6bdccacf02

View File

@ -312,7 +312,16 @@ bool cli_path_is_safe(String command)
String cli_resolve_unit_path(Request& request, String command, String& document_root)
{
document_root = first(request.params["DOCUMENT_ROOT"], cwd_get());
document_root = trim(first(request.params["DOCUMENT_ROOT"], request.server ? request.server->config["HTTP_DOCUMENT_ROOT"] : String("")));
if(document_root == "" && request.server)
{
String site_directory = trim(request.server->config["SITE_DIRECTORY"]);
String compiler_root = trim(request.server->config["COMPILER_SYS_PATH"]);
if(site_directory != "")
document_root = site_directory[0] == '/' ? site_directory : path_join(compiler_root, site_directory);
}
if(document_root == "")
document_root = cwd_get();
if(document_root.length() > 1 && document_root[document_root.length()-1] == '/')
document_root.resize(document_root.length()-1);