vendredi 23 février 2018

'+' symbol is getting replaced with space in a string when I read the url parameter in rails

Iam hitting a method in rails through ajax. The get url can be seen below,

/learners/-638284588?is_combined_page=true&email=test0221k+staging@tt.com&type=ld"

In log I can see the below entries,

  Started GET "/learners/-638284588?is_combined_page=true&    email=test0221k+staging@rosettastone.com&type=lcd" for 127.0.0.1 at Fri Feb 23 09:31:56 -0500 2018
  Processing by Extranet::LearnersController#show as HTML
  Parameters: {"type"=>"ld", "email"=>"test0221k staging@tt.com", "is_combined_page"=>"true", "id"=>"-638284588"}
  [WARNING] Audit logging has been enabled for Account
  parameter ----------------> {"type"=>"lcd", "email"=>"test0221k staging@tt.com", "controller"=>"extranet/learners", "is_combined_page"=>"true", "action"=>"show", "id"=>"-638284588"} test0221k staging@tt.com

In the GET request url email parameter can be seen as email="test0221k+staging@tt.com" which has a '+' sign in it. But this '+' sign is getting missed when I read the parameter as params[:email], i.e it is getting printed as "test0221k staging@tt.com".

'+' symbol is getting replaced with a space as you can see below. I don't know why it is happening.

Parameters: {"type"=>"ld", "email"=>"test0221k staging@tt.com", "is_combined_page"=>"true", "id"=>"-638284588"}

Why rails is over writing + with a space. How to avoid this "test0221k staging@tt.com" and get the actual email id like this "test0221k+staging@tt.com"

Can any one help me in this.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire