nginx: fix hkp routes

Changes handling of hkp routes:
- uri decode the search paramter before passing to /pks/internal/$op/$query
- strip <> surrounded text in lua, instead of an nginx rule
This commit is contained in:
Vincent Breitmoser 2019-09-12 13:48:35 +02:00
parent 8805cb7790
commit 52e863281d
1 changed files with 5 additions and 6 deletions

View File

@ -74,14 +74,13 @@ location /vks/v1/ {
# Common HKP requests.
location /pks/lookup {
# if the search argument contains angle brackets, strip everything around them
if ($arg_search ~ ".*\<([^&<>]+)\>.*") {
set $arg_search "$1";
}
# rewrite this to a path we can match on (right below)
if ($args ~ "op=.*search=") {
rewrite . /pks/internal/$arg_op/$arg_search last;
# urldecode the search parameter
set_by_lua $arg_search_decoded "return ngx.arg[1]:gsub(\"%%(%x%x)\", function(x) return string.char(tonumber(x, 16)) end)" $arg_search;
# if the search argument contains angle brackets, strip everything around them
set_by_lua $arg_search_decoded "return ngx.arg[1]:gsub(\"^.*<([^>]-)>.*$\", \"%1\")" $arg_search_decoded;
rewrite . /pks/internal/$arg_op/$arg_search_decoded last;
}
add_header 'Access-Control-Allow-Origin' '*';