Skip to content
Browse files

Removed the + sign as an accepted character from the parameterize met…

…hod, 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: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
1 parent d3a8152 commit f6f75e84c5a186ea4c689dd8b7ae0da391c226ef @stijnster stijnster committed with jeremy Mar 5, 2010
Showing with 7 additions and 4 deletions.
  1. +1 −1 activesupport/lib/active_support/inflector.rb
  2. +6 −3 activesupport/test/inflector_test_cases.rb
View
2 activesupport/lib/active_support/inflector.rb
@@ -260,7 +260,7 @@ def parameterize(string, sep = '-')
# replace accented chars with ther ascii equivalents
parameterized_string = transliterate(string)
# Turn unwanted chars into the seperator
- parameterized_string.gsub!(/[^a-z0-9\-_\+]+/i, sep)
+ parameterized_string.gsub!(/[^a-z0-9\-_]+/i, sep)
unless sep.blank?
re_sep = Regexp.escape(sep)
# No more than one of the separator in a row.
View
9 activesupport/test/inflector_test_cases.rb
@@ -151,23 +151,26 @@ 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 = {
"Donald E. Knuth" => "donaldeknuth",
"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 = {
"Donald E. Knuth" => "donald_e_knuth",
"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.

0 comments on commit f6f75e8

Please sign in to comment.
Something went wrong with that request. Please try again.