From 375259f34c9d8e0fb41da58bd2dc3c9f1494a6e1 Mon Sep 17 00:00:00 2001 From: Sam Eaton Date: Wed, 19 Oct 2016 02:30:58 -0600 Subject: [PATCH] Replace implementation with more appropriate URI.unescape (#231) --- src/kemal/param_parser.cr | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/kemal/param_parser.cr b/src/kemal/param_parser.cr index 86208f9..837aa5b 100644 --- a/src/kemal/param_parser.cr +++ b/src/kemal/param_parser.cr @@ -1,4 +1,5 @@ require "json" +require "uri" module Kemal # ParamParser parses the request contents including query_params and body @@ -21,8 +22,10 @@ module Kemal @json_parsed = false end - private def decode_url_param(value : String) - value.size == 0 ? value : HTTP::Params.parse(value).first[0]? + private def unescape_url_param(value : String) + value.size == 0 ? value : URI.unescape(value) + rescue + value end {% for method in %w(url query body json) %} @@ -49,7 +52,7 @@ module Kemal def parse_url if params = @request.url_params params.each do |key, value| - @url[key.as(String)] = decode_url_param(value).as(String) + @url[key.as(String)] = unescape_url_param(value).as(String) end end end