mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-26 03:16:18 +00:00
httpd: ssi: move checking file extensions against g_pcSSIExtensions array into its own function guarded by LWIP_HTTPD_SSI_BY_FILE_EXTENSION
This commit is contained in:
parent
5d6b39f1ce
commit
8bd670430a
@ -2087,6 +2087,47 @@ badrequest:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LWIP_HTTPD_SSI && (LWIP_HTTPD_SSI_BY_FILE_EXTENSION == 1)
|
||||||
|
/* Check if SSI should be parsed for this file/URL
|
||||||
|
* (With LWIP_HTTPD_SSI_BY_FILE_EXTENSION == 2, this function can be
|
||||||
|
* overridden by an external implementation.)
|
||||||
|
*
|
||||||
|
* @return 1 for SSI, 0 for standard files
|
||||||
|
*/
|
||||||
|
static u8_t
|
||||||
|
http_uri_is_ssi(struct fs_file *file, const char *uri)
|
||||||
|
{
|
||||||
|
size_t loop;
|
||||||
|
u8_t tag_check = 0;
|
||||||
|
if (file != NULL) {
|
||||||
|
/* See if we have been asked for an shtml file and, if so,
|
||||||
|
enable tag checking. */
|
||||||
|
const char *ext = NULL, *sub;
|
||||||
|
char *param = (char *)strstr(uri, "?");
|
||||||
|
if (param != NULL) {
|
||||||
|
/* separate uri from parameters for now, set back later */
|
||||||
|
*param = 0;
|
||||||
|
}
|
||||||
|
sub = uri;
|
||||||
|
ext = uri;
|
||||||
|
for (sub = strstr(sub, "."); sub != NULL; sub = strstr(sub, ".")) {
|
||||||
|
ext = sub;
|
||||||
|
sub++;
|
||||||
|
}
|
||||||
|
for (loop = 0; loop < NUM_SHTML_EXTENSIONS; loop++) {
|
||||||
|
if (!lwip_stricmp(ext, g_pcSSIExtensions[loop])) {
|
||||||
|
tag_check = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (param != NULL) {
|
||||||
|
*param = '?';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tag_check;
|
||||||
|
}
|
||||||
|
#endif /* LWIP_HTTPD_SSI */
|
||||||
|
|
||||||
/** Try to find the file specified by uri and, if found, initialize hs
|
/** Try to find the file specified by uri and, if found, initialize hs
|
||||||
* accordingly.
|
* accordingly.
|
||||||
*
|
*
|
||||||
@ -2193,33 +2234,8 @@ http_find_file(struct http_state *hs, const char *uri, int is_09)
|
|||||||
} else {
|
} else {
|
||||||
file = http_get_404_file(hs, &uri);
|
file = http_get_404_file(hs, &uri);
|
||||||
}
|
}
|
||||||
#if LWIP_HTTPD_SSI
|
#if LWIP_HTTPD_SSI && LWIP_HTTPD_SSI_BY_FILE_EXTENSION
|
||||||
if (file != NULL) {
|
tag_check = http_uri_is_ssi(file, uri);
|
||||||
/* See if we have been asked for an shtml file and, if so,
|
|
||||||
enable tag checking. */
|
|
||||||
const char *ext = NULL, *sub;
|
|
||||||
char *param = (char *)strstr(uri, "?");
|
|
||||||
if (param != NULL) {
|
|
||||||
/* separate uri from parameters for now, set back later */
|
|
||||||
*param = 0;
|
|
||||||
}
|
|
||||||
sub = uri;
|
|
||||||
ext = uri;
|
|
||||||
for (sub = strstr(sub, "."); sub != NULL; sub = strstr(sub, ".")) {
|
|
||||||
ext = sub;
|
|
||||||
sub++;
|
|
||||||
}
|
|
||||||
tag_check = 0;
|
|
||||||
for (loop = 0; loop < NUM_SHTML_EXTENSIONS; loop++) {
|
|
||||||
if (!lwip_stricmp(ext, g_pcSSIExtensions[loop])) {
|
|
||||||
tag_check = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (param != NULL) {
|
|
||||||
*param = '?';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* LWIP_HTTPD_SSI */
|
#endif /* LWIP_HTTPD_SSI */
|
||||||
}
|
}
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
|
@ -109,6 +109,18 @@
|
|||||||
#define LWIP_HTTPD_SSI_RAW 0
|
#define LWIP_HTTPD_SSI_RAW 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/** Set this to 0 to prevent parsing the file extension at runtime to decide
|
||||||
|
* if a file should be scanned for SSI tags or not.
|
||||||
|
* Default is 1 (file extensions are checked using the g_pcSSIExtensions array)
|
||||||
|
* Set to 2 to override this runtime test function.
|
||||||
|
*
|
||||||
|
* This is enabled by default, but if you only use a newer version of makefsdata
|
||||||
|
* supporting the "-ssi" option, this info is already present in
|
||||||
|
*/
|
||||||
|
#if !defined LWIP_HTTPD_SSI_BY_FILE_EXTENSION || defined __DOXYGEN__
|
||||||
|
#define LWIP_HTTPD_SSI_BY_FILE_EXTENSION 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Set this to 1 to support HTTP POST */
|
/** Set this to 1 to support HTTP POST */
|
||||||
#if !defined LWIP_HTTPD_SUPPORT_POST || defined __DOXYGEN__
|
#if !defined LWIP_HTTPD_SUPPORT_POST || defined __DOXYGEN__
|
||||||
#define LWIP_HTTPD_SUPPORT_POST 0
|
#define LWIP_HTTPD_SUPPORT_POST 0
|
||||||
|
Loading…
Reference in New Issue
Block a user