/*
- * uhttpd - Tiny non-forking httpd - Main component
+ * uhttpd - Tiny single-threaded httpd - Main component
*
* Copyright (C) 2010 Jo-Philipp Wich <xm@subsignal.org>
*
return NULL;
}
+static int uh_path_match(const char *prefix, const char *url)
+{
+ if( (strstr(url, prefix) == url) &&
+ ((prefix[strlen(prefix)-1] == '/') ||
+ (strlen(url) == strlen(prefix)) ||
+ (url[strlen(prefix)] == '/'))
+ ) {
+ return 1;
+ }
+
+ return 0;
+}
+
int main (int argc, char **argv)
{
{
#ifdef HAVE_LUA
/* Lua request? */
- if( L && strstr(req->url, conf.lua_prefix) == req->url )
+ if( L && uh_path_match(conf.lua_prefix, req->url) )
{
uh_lua_request(cl, req, L);
}
if( uh_auth_check(cl, req, pin) )
{
#ifdef HAVE_CGI
- if( strstr(pin->name, conf.cgi_prefix) == pin->name )
+ if( uh_path_match(conf.cgi_prefix, pin->name) )
{
uh_cgi_request(cl, req, pin);
}