diff --git a/UserManual.md b/UserManual.md index 8590dcea335ad99731661b093fb5c38074de34dd..e5474a3f6dec5318a4ff823d89d91ef03f75f87b 100644 --- a/UserManual.md +++ b/UserManual.md @@ -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 diff --git a/mongoose.c b/mongoose.c index 54bee01dedd891349f0a5edf085232e2aa399f26..89ed4144dce5421c1b6e98972e6d2d874e4e19f6 100644 --- a/mongoose.c +++ b/mongoose.c @@ -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) { diff --git a/test/ssi1.shtml b/test/ssi1.shtml index 0dd64a2e7f5af0ddff7841f965bb94659ffd0460..9bffef9c1e271944de50478f26b5653c6e3a50e6 100644 --- a/test/ssi1.shtml +++ b/test/ssi1.shtml @@ -1,5 +1,5 @@ <html><pre> ssi_begin -<!--#include file="Makefile" --> +<!--#include file="../Makefile" --> ssi_end </pre></html> diff --git a/test/ssi5.shtml b/test/ssi5.shtml index de3e49b80adf9a8786697aa002febebc6d9ab839..1db2a7823db5545f7a9dd33d686f4758ac63e837 100644 --- a/test/ssi5.shtml +++ b/test/ssi5.shtml @@ -1,5 +1,5 @@ <html><pre> ssi_begin -<!--#include file="/etc/passwd" --> +<!--#include abspath="/etc/passwd" --> ssi_end </pre></html> diff --git a/test/ssi6.shtml b/test/ssi6.shtml index 2fd8b51088f31bbd22855fabdab3425443699cf2..4359baafafad3c4b99566dd3945f847a4037db40 100644 --- a/test/ssi6.shtml +++ b/test/ssi6.shtml @@ -1,5 +1,5 @@ <html><pre> ssi_begin -<!--#include file="c:\boot.ini" --> +<!--#include abspath="c:\boot.ini" --> ssi_end </pre></html> diff --git a/test/ssi9.shtml b/test/ssi9.shtml index 92030759f02f97b02b027fc14fae402c9f63c43c..4e837782612f079786b822b03d396953539f6515 100644 --- a/test/ssi9.shtml +++ b/test/ssi9.shtml @@ -1,3 +1,3 @@ ssi_begin -<!--#include file="Makefile" --> +<!--#include file="../Makefile" --> ssi_end diff --git a/test/test.pl b/test/test.pl index 45d1865b46adbe59137facdb9795b1df43057e83..d455741e50a4db179c7ae3417fad91aa7e1e66a5 100644 --- a/test/test.pl +++ b/test/test.pl @@ -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",