openwrt/luci — pull request #269 by seamusmurray (2014-12-20 03:56:34+00:00)
Title: luci.http: fix wrong SCRIPT_NAME under mini_httpd

The SCRIPT_NAME CGI environment variable should be set to the path of
the current CGI executable, relative to the document root. On a default
OpenWrt installation, this would be "/cgi-bin/luci".

Under mini_httpd, the SCRIPT_NAME variable is set correctly as long as
virtual hosts are not enabled. When virtual hosts are enabled, however,
the SCRIPT_NAME set by mini_httpd incorrectly includes the rest of the
URI after the script name. Because LuCI uses the SCRIPT_NAME variable
to build URLs, the web interface is made unusable.

This commit provides a workaround for the incorrect SCRIPT_NAME. Before
the CGI environment variables are read into the table used by getenv(),
SCRIPT_NAME is modified by stripping the part of the string beginning
with "/;". getenv() will now return the correct value for SCRIPT_NAME,
and all code that relies on it will work properly.

Signed-off-by: Seamus Murray