From 6d3bcc867ca8741b26cfcb5032eb991b2423d843 Mon Sep 17 00:00:00 2001 From: Uriel Date: Sun, 19 Aug 2012 01:16:10 +0200 Subject: [PATCH] Be a bit more careful before we redirect to plain files when we get a trailing / and can't find a dir. --- bin/werc.rc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/werc.rc b/bin/werc.rc index dccfc60..1b6b7dd 100755 --- a/bin/werc.rc +++ b/bin/werc.rc @@ -61,9 +61,15 @@ fn werc_exec_request { if(~ $local_path */) { if(test -d $local_path) local_path=$local_path^'index' + + # If path has a trailing /, and a plain file exists matching that 'name.*' + # remove the traling / and redirect to 'name' . # XXX: This redir might step on apps with synthetic dirs. - if not if(ls `{basename -d $local_path}^* >/dev/null >[2]/dev/null) - perm_redirect `{echo $req_path|sed 's,/+$,,'} + if not { + # TODO: Maybe we should be smarter about how to check for existing files + if(ls `{basename -d $local_path}^'.*' >/dev/null >[2]/dev/null) + perm_redirect `{echo $req_path|sed 's,/+$,,'} + } } if not if(~ $req_path *'.' *',' *';' *':') perm_redirect `{echo $req_path | sed 's/[.,;:)]$//'}