Skip to content

Commit

Permalink
Removed the + sign as an accepted character from the parameterize met…
Browse files Browse the repository at this point in the history
…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
stijnster authored and jeremy committed Mar 5, 2010
1 parent e472f76 commit 67512b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Expand Up @@ -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.
Expand Down
9 changes: 6 additions & 3 deletions activesupport/test/inflector_test_cases.rb
Expand Up @@ -158,23 +158,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.
Expand Down

0 comments on commit 67512b9

Please sign in to comment.