Commit e003236a authored by Sergey Lyubka's avatar Sergey Lyubka

Made SSI #include file= relative to the current doc, as per spec

parent de774537
......@@ -143,8 +143,10 @@ directives are supported, `<!--#include ...>` and
three path specifications:
<!--#include virtual="path"> Path is relative to web server root
<!--#include file="path"> Path is relative to web server working dir
<!--#include "path"> Path is relative to current document
<!--#include abspath="path"> Path is absolute or relative to
web server working dir
<!--#include file="path">, Path is relative to current document
<!--#include "path">
The `include` directive may be used to include the contents of a file or the
result of running a CGI script. The `exec` directive is used to execute a
......
......@@ -3611,11 +3611,12 @@ static void do_ssi_include(struct mg_connection *conn, const char *ssi,
// File name is relative to the webserver root
(void) mg_snprintf(conn, path, sizeof(path), "%s%c%s",
conn->ctx->config[DOCUMENT_ROOT], '/', file_name);
} else if (sscanf(tag, " file=\"%[^\"]\"", file_name) == 1) {
} else if (sscanf(tag, " abspath=\"%[^\"]\"", file_name) == 1) {
// File name is relative to the webserver working directory
// or it is absolute system path
(void) mg_snprintf(conn, path, sizeof(path), "%s", file_name);
} else if (sscanf(tag, " \"%[^\"]\"", file_name) == 1) {
} else if (sscanf(tag, " file=\"%[^\"]\"", file_name) == 1 ||
sscanf(tag, " \"%[^\"]\"", file_name) == 1) {
// File name is relative to the currect document
(void) mg_snprintf(conn, path, sizeof(path), "%s", ssi);
if ((p = strrchr(path, '/')) != NULL) {
......
<html><pre>
ssi_begin
<!--#include file="Makefile" -->
<!--#include file="../Makefile" -->
ssi_end
</pre></html>
<html><pre>
ssi_begin
<!--#include file="/etc/passwd" -->
<!--#include abspath="/etc/passwd" -->
ssi_end
</pre></html>
<html><pre>
ssi_begin
<!--#include file="c:\boot.ini" -->
<!--#include abspath="c:\boot.ini" -->
ssi_end
</pre></html>
ssi_begin
<!--#include file="Makefile" -->
<!--#include file="../Makefile" -->
ssi_end
......@@ -403,7 +403,7 @@ unless (scalar(@ARGV) > 0 and $ARGV[0] eq "basic_tests") {
my $abs_path = on_windows() ? 'ssi6.shtml' : 'ssi5.shtml';
my $word = on_windows() ? 'boot loader' : 'root';
o("GET /$abs_path HTTP/1.0\n\n",
"ssi_begin.+$word.+ssi_end", 'SSI #include file= (absolute)');
"ssi_begin.+$word.+ssi_end", 'SSI #include abspath');
o("GET /ssi7.shtml HTTP/1.0\n\n",
'ssi_begin.+Unit test.+ssi_end', 'SSI #include "..."');
o("GET /ssi8.shtml HTTP/1.0\n\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment