提交 67512b94 编写于 作者: S Stijn Mathysen 提交者: Jeremy Kemper

Removed the + sign as an accepted character from the parameterize method, as a...

Removed the + sign as an accepted character from the parameterize method, as a + sign is interpreted by the browser as a space, possibly resulting in a "ArgumentError: illegal character in key"

[#4080 state:committed]
Signed-off-by: NJeremy Kemper <jeremy@bitsweat.net>
上级 e472f76e
......@@ -47,7 +47,7 @@ def parameterize(string, sep = '-')
# replace accented chars with their ascii equivalents
parameterized_string = transliterate(string)
# Turn unwanted chars into the separator
parameterized_string.gsub!(/[^a-z0-9\-_\+]+/i, sep)
parameterized_string.gsub!(/[^a-z0-9\-_]+/i, sep)
unless sep.nil? || sep.empty?
re_sep = Regexp.escape(sep)
# No more than one of the separator in a row.
......
......@@ -158,7 +158,8 @@ module InflectorTestCases
"Allow_Under_Scores" => "allow_under_scores",
"Trailing bad characters!@#" => "trailing-bad-characters",
"!@#Leading bad characters" => "leading-bad-characters",
"Squeeze separators" => "squeeze-separators"
"Squeeze separators" => "squeeze-separators",
"Test with + sign" => "test-with-sign"
}
StringToParameterizeWithNoSeparator = {
......@@ -166,7 +167,8 @@ module InflectorTestCases
"Random text with *(bad)* characters" => "randomtextwithbadcharacters",
"Trailing bad characters!@#" => "trailingbadcharacters",
"!@#Leading bad characters" => "leadingbadcharacters",
"Squeeze separators" => "squeezeseparators"
"Squeeze separators" => "squeezeseparators",
"Test with + sign" => "testwithsign"
}
StringToParameterizeWithUnderscore = {
......@@ -174,7 +176,8 @@ module InflectorTestCases
"Random text with *(bad)* characters" => "random_text_with_bad_characters",
"Trailing bad characters!@#" => "trailing_bad_characters",
"!@#Leading bad characters" => "leading_bad_characters",
"Squeeze separators" => "squeeze_separators"
"Squeeze separators" => "squeeze_separators",
"Test with + sign" => "test_with_sign"
}
# Ruby 1.9 doesn't do Unicode normalization yet.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册