Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

ruby - Rails: Plus sign in GET-Request replaced by space

In Rails 3 (Ruby 1.9.2) I send an request

 Started GET "/controller/action?path=/41_+"

But the parameter list looks like this:

 {"path"=>"/41_ ",
   "controller"=>"controller",
   "action"=>"action"}

Whats going wrong here? The -, * or . sign works fine, its just the +which will be replaced by a space.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

That's normal URL encoding, the plus sign is a shorthand for a space:

Within the query string, the plus sign is reserved as shorthand notation for a space. Therefore, real plus signs must be encoded. This method was used to make query URIs easier to pass in systems which did not allow spaces.

And from the HTML5 standard:

The character is a U+0020 SPACE character
Replace the character with a single U+002B PLUS SIGN character (+).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...