diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-05-02 13:08:47 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-05-02 13:08:47 +0100 |
commit | 8bf293b76f13aa37c6f627057bd71e486cd29c65 (patch) | |
tree | 3cfa15b41e4062e207345556bf85596265677913 /src | |
parent | 1bdd6b9b770fe11c3167e3365b236041a2f5582a (diff) | |
download | rspamd-8bf293b76f13aa37c6f627057bd71e486cd29c65.tar.gz rspamd-8bf293b76f13aa37c6f627057bd71e486cd29c65.zip |
Serve files in subdirs.
Diffstat (limited to 'src')
-rw-r--r-- | src/libutil/http.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/libutil/http.c b/src/libutil/http.c index 22f870262..2f649e477 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -1050,6 +1050,29 @@ rspamd_http_router_detect_ct (const gchar *path) } static gboolean +rspamd_http_router_is_subdir (const gchar *parent, const gchar *sub) +{ + if (parent == NULL || sub == NULL || *parent == '\0') { + return FALSE; + } + + while (*parent != '\0') { + if (*sub != *parent) { + return FALSE; + } + parent ++; + sub ++; + } + + parent --; + if (*parent == G_DIR_SEPARATOR) { + return TRUE; + } + + return (*sub == G_DIR_SEPARATOR || *sub == '\0'); +} + +static gboolean rspamd_http_router_try_file (struct rspamd_http_connection_entry *entry, struct rspamd_http_message *msg, gboolean expand_path) { @@ -1086,7 +1109,8 @@ rspamd_http_router_try_file (struct rspamd_http_connection_entry *entry, /* We also need to ensure that file is inside the defined dir */ rspamd_strlcpy (filebuf, realbuf, sizeof (filebuf)); dir = dirname (filebuf); - if (dir == NULL || strcmp (dir, entry->rt->default_fs_path) != 0) { + if (dir == NULL || !rspamd_http_router_is_subdir (entry->rt->default_fs_path, + dir)) { return FALSE; } |