Commit 6e2773a4 authored by Philipp Schafft's avatar Philipp Schafft 🦁

Merged update for file extension check

Closes: #2248
parents 805084cc c8f565b0
......@@ -197,35 +197,23 @@ char *util_get_extension(const char *path) {
}
int util_check_valid_extension(const char *uri) {
int ret = 0;
char *p2;
if (uri) {
p2 = strrchr(uri, '.');
if (p2) {
p2++;
if (strncmp(p2, "xsl", strlen("xsl")) == 0) {
/* Build the full path for the request, concatenating the webroot from the config.
** Here would be also a good time to prevent accesses like '../../../../etc/passwd' or somesuch.
*/
ret = XSLT_CONTENT;
}
if (strncmp(p2, "htm", strlen("htm")) == 0) {
/* Build the full path for the request, concatenating the webroot from the config.
** Here would be also a good time to prevent accesses like '../../../../etc/passwd' or somesuch.
*/
ret = HTML_CONTENT;
}
if (strncmp(p2, "html", strlen("html")) == 0) {
/* Build the full path for the request, concatenating the webroot from the config.
** Here would be also a good time to prevent accesses like '../../../../etc/passwd' or somesuch.
*/
ret = HTML_CONTENT;
}
const char *p2;
}
if (!uri)
return UNKNOWN_CONTENT;
p2 = strrchr(uri, '.');
if (!p2)
return UNKNOWN_CONTENT;
p2++;
if (strcmp(p2, "xsl") == 0 || strcmp(p2, "xslt") == 0) {
return XSLT_CONTENT;
} else if (strcmp(p2, "htm") == 0 || strcmp(p2, "html") == 0) {
return HTML_CONTENT;
}
return ret;
return UNKNOWN_CONTENT;
}
static int hex(char c)
......
......@@ -17,8 +17,9 @@
/* for FILE* */
#include <stdio.h>
#define XSLT_CONTENT 1
#define HTML_CONTENT 2
#define UNKNOWN_CONTENT 0
#define XSLT_CONTENT 1
#define HTML_CONTENT 2
#define READ_ENTIRE_HEADER 1
#define READ_LINE 0
......
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