@@ 38,7 38,7 @@ use futures_lite::{
use is_executable::IsExecutable;
use log::{debug, error};
use sha2::{Digest, Sha256};
-use std::time::Duration;
+use std::{ffi::{OsStr, OsString}, time::Duration};
use std::{collections::HashMap, net::IpAddr};
use std::{
io::ErrorKind,
@@ 96,8 96,13 @@ pub async fn serve_cgi<'a>(
common_vars(domain, req, remote_addr, server_port, &session).await?,
);
cmd.env("GATEWAY_INTERFACE", "CGI/1.1");
- cmd.env("SCRIPT_NAME", script_name);
- cmd.env("PATH_INFO", path_info);
+ fn add_leading_slash(s: &OsStr) -> OsString {
+ let mut new = OsString::from("/");
+ new.push(s);
+ new
+ }
+ cmd.env("SCRIPT_NAME", add_leading_slash(script_name.as_os_str()));
+ cmd.env("PATH_INFO", add_leading_slash(path_info.as_os_str()));
cmd.stdout(Stdio::piped());
cmd.stderr(Stdio::piped());