Rails:用空格取代GET-Request [英] Rails: Plus sign in GET-Request replaced by space
问题描述
开始GET/ controller / action?path = / 41_ +
但参数列表如下所示:
{path=>/ 41_,
controller=>controller,
action=> ;action}
这里怎么回事? -
, *
或。
标志正常工作,只是 +
这将被一个空格替换。 这是正常的URL编码,加号是空格的简写:
在查询字符串中,加号被保留为空格的简写符号。因此,真正的加号必须被编码。此方法用于使查询URI更容易在不允许空格的系统中传递。
从HTML5标准:
该字符是U + 0020 SPACE字符
用一个U + 002B PLUS SIGN字符替换该字符+)。
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.
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 (+).
这篇关于Rails:用空格取代GET-Request的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!