diff options
Diffstat (limited to 'server_http.c')
-rw-r--r-- | server_http.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/server_http.c b/server_http.c index 3a5d84e..d83c7b4 100644 --- a/server_http.c +++ b/server_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_http.c,v 1.58 2015/01/01 14:15:02 reyk Exp $ */ +/* $OpenBSD: server_http.c,v 1.59 2015/01/04 22:23:58 chrisz Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -887,6 +887,21 @@ server_response(struct httpd *httpd, struct client *clt) return (-1); } +const char * +server_root_strip(const char *path, int n) +{ + const char *p; + + /* Strip strip leading directories. Leading '/' is ignored. */ + for (; n > 0 && *path != '\0'; n--) + if ((p = strchr(++path, '/')) == NULL) + path = strchr(path, '\0'); + else + path = p; + + return (path); +} + struct server_config * server_getlocation(struct client *clt, const char *path) { |