mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-06 15:51:25 +00:00
Keep directory listing compile-time option
This commit is contained in:
1 parent
3808dd3222
commit
0d5d7bb26f
5 files changed
+2
-17
No files matched your search
+1
-5
@@ -1279,11 +1279,7 @@ void mg_http_serve_dir(struct mg_connection *c, struct mg_http_message *hm,
|
|||||||
#endif
|
#endif
|
||||||
if (is_index && fp == NULL) {
|
if (is_index && fp == NULL) {
|
||||||
#if MG_ENABLE_DIRECTORY_LISTING
|
#if MG_ENABLE_DIRECTORY_LISTING
|
||||||
if (opts->enable_dirlist && strcmp(opts->enable_dirlist, "no") == 0) {
|
listdir(c, hm, opts, t2);
|
||||||
mg_http_reply(c, 403, "", "%s", "Denied");
|
|
||||||
} else {
|
|
||||||
listdir(c, hm, opts, t2);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
mg_http_reply(c, 403, "", "%s", "Directory listing not supported");
|
mg_http_reply(c, 403, "", "%s", "Directory listing not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -787,7 +787,6 @@ struct mg_http_serve_opts {
|
|||||||
const char *root_dir; // Web root directory, must be non-NULL
|
const char *root_dir; // Web root directory, must be non-NULL
|
||||||
const char *ssi_pattern; // SSI file name pattern, e.g. #.shtml
|
const char *ssi_pattern; // SSI file name pattern, e.g. #.shtml
|
||||||
const char *extra_headers; // Extra HTTP headers to add in responses
|
const char *extra_headers; // Extra HTTP headers to add in responses
|
||||||
const char *enable_dirlist; // Enable dir listing. Set to "no" to disable
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Parameter for mg_http_next_multipart
|
// Parameter for mg_http_next_multipart
|
||||||
|
|||||||
+1
-5
@@ -868,11 +868,7 @@ void mg_http_serve_dir(struct mg_connection *c, struct mg_http_message *hm,
|
|||||||
#endif
|
#endif
|
||||||
if (is_index && fp == NULL) {
|
if (is_index && fp == NULL) {
|
||||||
#if MG_ENABLE_DIRECTORY_LISTING
|
#if MG_ENABLE_DIRECTORY_LISTING
|
||||||
if (opts->enable_dirlist && strcmp(opts->enable_dirlist, "no") == 0) {
|
listdir(c, hm, opts, t2);
|
||||||
mg_http_reply(c, 403, "", "%s", "Denied");
|
|
||||||
} else {
|
|
||||||
listdir(c, hm, opts, t2);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
mg_http_reply(c, 403, "", "%s", "Directory listing not supported");
|
mg_http_reply(c, 403, "", "%s", "Directory listing not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ struct mg_http_serve_opts {
|
|||||||
const char *root_dir; // Web root directory, must be non-NULL
|
const char *root_dir; // Web root directory, must be non-NULL
|
||||||
const char *ssi_pattern; // SSI file name pattern, e.g. #.shtml
|
const char *ssi_pattern; // SSI file name pattern, e.g. #.shtml
|
||||||
const char *extra_headers; // Extra HTTP headers to add in responses
|
const char *extra_headers; // Extra HTTP headers to add in responses
|
||||||
const char *enable_dirlist; // Enable dir listing. Set to "no" to disable
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Parameter for mg_http_next_multipart
|
// Parameter for mg_http_next_multipart
|
||||||
|
|||||||
@@ -369,7 +369,6 @@ static void eh1(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
|||||||
sopts.root_dir = "./test/data";
|
sopts.root_dir = "./test/data";
|
||||||
sopts.ssi_pattern = "#.shtml";
|
sopts.ssi_pattern = "#.shtml";
|
||||||
sopts.extra_headers = "C: D\r\n";
|
sopts.extra_headers = "C: D\r\n";
|
||||||
sopts.enable_dirlist = "no";
|
|
||||||
mg_http_serve_dir(c, hm, &sopts);
|
mg_http_serve_dir(c, hm, &sopts);
|
||||||
}
|
}
|
||||||
} else if (ev == MG_EV_WS_MSG) {
|
} else if (ev == MG_EV_WS_MSG) {
|
||||||
@@ -565,10 +564,6 @@ static void test_http_server(void) {
|
|||||||
ASSERT(mg_strstr(mg_str(buf), mg_str(">Index of /test/<")) != NULL);
|
ASSERT(mg_strstr(mg_str(buf), mg_str(">Index of /test/<")) != NULL);
|
||||||
ASSERT(mg_strstr(mg_str(buf), mg_str(">fuzz.c<")) != NULL);
|
ASSERT(mg_strstr(mg_str(buf), mg_str(">fuzz.c<")) != NULL);
|
||||||
|
|
||||||
// Directory listing denied
|
|
||||||
ASSERT(fetch(&mgr, buf, url, "GET /secret/ HTTP/1.0\n\n") == 403);
|
|
||||||
ASSERT(cmpbody(buf, "Denied\n") == 0);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Credentials
|
// Credentials
|
||||||
struct mg_http_message hm;
|
struct mg_http_message hm;
|
||||||
|
|||||||
Reference in new issue
Block a user