Rewrite redirect handling code with nested lists.
New ll_addh to add items to the head of a nested list (use with care!).
This commit is contained in:
parent
673bdaf664
commit
588c035b3b
3 changed files with 17 additions and 14 deletions
22
bin/werc.rc
22
bin/werc.rc
|
|
@ -89,20 +89,16 @@ fn werc_exec_request {
|
|||
|
||||
if(~ $#perm_redir_to 1)
|
||||
perm_redirect $perm_redir_to
|
||||
p=();
|
||||
for(i in $perm_redir_patterns) {
|
||||
if(~ $#p 0)
|
||||
p=$i
|
||||
if not {
|
||||
# If target is absolute, require patern matches whole string
|
||||
if(~ $i http://* https://)
|
||||
p='^'$p
|
||||
t=`{ echo $req_path | sed 's!'$p'!'$i'!' }
|
||||
for(l in $perm_redir_patterns) {
|
||||
p=$$l
|
||||
r=$p(1)
|
||||
# If target is absolute, then patern must match whole string
|
||||
if(~ $p(2) http://* https://)
|
||||
r='^'$r
|
||||
t=`{ echo $req_path | sed 's!'^$r^'!'^$p(2)^'!' } # Malicious danger!
|
||||
|
||||
if(! ~ $"t '' && ! ~ $t $req_path)
|
||||
perm_redirect $t
|
||||
p=()
|
||||
}
|
||||
if(! ~ $"t '' $req_path)
|
||||
perm_redirect $t
|
||||
}
|
||||
|
||||
# Set Page title
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue