2
0
Fork 0

Append slash to doc-root for physical path if it is missing

This commit is contained in:
Stefan Bühler 2009-09-14 21:45:52 +02:00
parent 1aeed6c222
commit f31572bef1
2 changed files with 9 additions and 0 deletions

View File

@ -41,6 +41,9 @@ LI_API void li_url_decode(GString *path);
LI_API void li_path_simplify(GString *path);
/* ensures path has a trailing slash */
INLINE void li_path_append_slash(GString *path);
/* finds the first value for a given key in the querystring. works with '&' as well as ';' delimiters */
LI_API gboolean li_querystring_find(GString *querystring, const gchar *key, const guint key_len, gchar **val, guint *val_len);
@ -101,3 +104,8 @@ LI_API GQuark li_sys_error_quark();
LI_API gboolean _li_set_sys_error(GError **error, const gchar *msg, const gchar *file, int lineno);
#endif
INLINE void li_path_append_slash(GString *path) {
if (path->len == 0 || path->str[path->len-1] != '/')
g_string_append_len(path, "/", 1);
}

View File

@ -162,6 +162,7 @@ static liHandlerResult core_handle_docroot(liVRequest *vr, gpointer param, gpoin
/* build physical path: docroot + uri.path */
g_string_truncate(vr->physical.path, 0);
g_string_append_len(vr->physical.path, GSTR_LEN(vr->physical.doc_root));
li_path_append_slash(vr->physical.path);
g_string_append_len(vr->physical.path, GSTR_LEN(vr->request.uri.path));
VR_DEBUG(vr, "physical path: %s", vr->physical.path->str);