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

This commit is contained in:
Sergey Lyubka committed 2013-07-19 07:57:47 +01:00
1 parent de7745370c
commit e003236a03
7 files changed
+12 -9

No files matched your search

+4 -2
View File
@@ -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
+3 -2
View File
@@ -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) {
+1 -1
View File
@@ -1,5 +1,5 @@
<html><pre>
ssi_begin
<!--#include file="Makefile" -->
<!--#include file="../Makefile" -->
ssi_end
</pre></html>
+1 -1
View File
@@ -1,5 +1,5 @@
<html><pre>
ssi_begin
<!--#include file="/etc/passwd" -->
<!--#include abspath="/etc/passwd" -->
ssi_end
</pre></html>
+1 -1
View File
@@ -1,5 +1,5 @@
<html><pre>
ssi_begin
<!--#include file="c:\boot.ini" -->
<!--#include abspath="c:\boot.ini" -->
ssi_end
</pre></html>
+1 -1
View File
@@ -1,3 +1,3 @@
ssi_begin
<!--#include file="Makefile" -->
<!--#include file="../Makefile" -->
ssi_end
+1 -1
View File
@@ -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",