Rails:加号 GET-Request 被空格取代 [英] Rails: Plus sign in GET-Request replaced by space
问题描述
在 Rails 3 (Ruby 1.9.2) 中,我发送请求
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.
推荐答案
那是正常的 URL 编码,加号是空格的简写:
That's normal URL encoding, the plus sign is a shorthand for a space:
在查询字符串中,加号被保留为空格的速记符号.因此,必须对实数加号进行编码.此方法用于使查询 URI 更容易在不允许空格的系统中传递.
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.
来自 HTML5 标准一个>:
字符是 U+0020 空格字符
用单个 U+002B 加号字符 (+) 替换该字符.
The character is a U+0020 SPACE character
Replace the character with a single U+002B PLUS SIGN character (+).
这篇关于Rails:加号 GET-Request 被空格取代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!