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
|
|
@ -157,6 +157,13 @@ fn ll_add {
|
||||||
$_l=$*(2-)
|
$_l=$*(2-)
|
||||||
$1=( $$1 $_l )
|
$1=( $$1 $_l )
|
||||||
}
|
}
|
||||||
|
# Add to the head: dangerous if you shrink list by hand!
|
||||||
|
fn ll_addh {
|
||||||
|
_l=$1^_^$#$1
|
||||||
|
$_l=$*(2-)
|
||||||
|
$1=( $_l $$1 )
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NEW_LINE='
|
NEW_LINE='
|
||||||
'
|
'
|
||||||
|
|
|
||||||
22
bin/werc.rc
22
bin/werc.rc
|
|
@ -89,20 +89,16 @@ fn werc_exec_request {
|
||||||
|
|
||||||
if(~ $#perm_redir_to 1)
|
if(~ $#perm_redir_to 1)
|
||||||
perm_redirect $perm_redir_to
|
perm_redirect $perm_redir_to
|
||||||
p=();
|
for(l in $perm_redir_patterns) {
|
||||||
for(i in $perm_redir_patterns) {
|
p=$$l
|
||||||
if(~ $#p 0)
|
r=$p(1)
|
||||||
p=$i
|
# If target is absolute, then patern must match whole string
|
||||||
if not {
|
if(~ $p(2) http://* https://)
|
||||||
# If target is absolute, require patern matches whole string
|
r='^'$r
|
||||||
if(~ $i http://* https://)
|
t=`{ echo $req_path | sed 's!'^$r^'!'^$p(2)^'!' } # Malicious danger!
|
||||||
p='^'$p
|
|
||||||
t=`{ echo $req_path | sed 's!'$p'!'$i'!' }
|
|
||||||
|
|
||||||
if(! ~ $"t '' && ! ~ $t $req_path)
|
if(! ~ $"t '' $req_path)
|
||||||
perm_redirect $t
|
perm_redirect $t
|
||||||
p=()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set Page title
|
# Set Page title
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ fn conf_perm_redirect {
|
||||||
if(~ $#* 1)
|
if(~ $#* 1)
|
||||||
perm_redir_to=$1
|
perm_redir_to=$1
|
||||||
if not
|
if not
|
||||||
perm_redir_patterns=($1 $2 $perm_redir_patterns)
|
ll_addh perm_redir_patterns $1 $2
|
||||||
}
|
}
|
||||||
|
|
||||||
fn conf_hide_paths {
|
fn conf_hide_paths {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue