diff --git a/hagrid-routes.conf b/hagrid-routes.conf index d5263fa..613ea5e 100644 --- a/hagrid-routes.conf +++ b/hagrid-routes.conf @@ -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' '*';