I'm adding full-text search to my Rails site and allowing users to enter double quotes in the search input box. The problem is that the double quotes seem to get filtered out by Mongrel and so I never receive those quotes in the values of the params hash. How do I prevent this from happening? I'm running Rails 2.3.8.
[Edit: added analysis data]
In Firebug I see the post parameter being posted correctly with quotes:
search_criteria "great post"
In the development log, however, the quotes are gone:
Processing PostsController#search (for 127.0.0.1 at 2010-06-18 17:28:45) [POST] Parameters: {"search_criteria"=>"great post", "action"=>"search", "authenticity_token"=>"xUaOc1IAyjQmKn1NGqBpPVaTBmD4ayPq/lUJsqJGCxY=", "controller"=>"posts"}
And when I log the contents and size of params[:search_criteria] in the controller, I get:
search criteria = great post
search criteria size = 10
[Edit: new discovery] This problem described above does not occur when the quoted string is trailed or preceded by another character, e.g. a space.
Apparently this is a bug in rack 1.1.0. The fix [patch here] was made for rack 1.2.0. However, actionpack (and thus, rails) 2.3.6 through 2.3.10 depend on rack ~> 1.1.0, so they all have this problem.
Potential solutions with most likely actually happening ordered first...
This question has tips on how to patch rack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With