serverless-rack icon indicating copy to clipboard operation
serverless-rack copied to clipboard

Query parameters are not being parsed

Open rickselby opened this issue 4 years ago • 1 comments

I'm using this as a gem for a Sinatra app running in an AWS lambda. I'm having issues making a request with a query parameter containing a string (e.g. GET /user-record/users?q=ddd%20d). In my local environment (using rack), the params hash contains the query with a space ({"q"=>"ddd d"}), but in AWS, it comes through with the %20 ({"q"=>"ddd%20d"}).

I think this is because Rack::Utils.build_query (called in parse_query_string) is calling Rack::Utils.escape on all the parameters, so they're effectively double escaped.

I think the result of build_query needs to be unescaped for this to function properly?

rickselby avatar Jan 19 '21 13:01 rickselby

Hi @rickselby, it sounds like you're on the right track. In that case, we might need to differentiate between the local and AWS environment or, perhaps preferably, add some middleware when serving locally to mimic AWS.

logandk avatar Jan 21 '21 08:01 logandk