From 62866fbee504626ba1058d0d3f7a5200158f797c Mon Sep 17 00:00:00 2001 From: Stijn Mathysen Date: Fri, 5 Mar 2010 20:04:57 -0200 Subject: [PATCH] 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" --- activesupport/lib/active_support/inflector.rb | 2 +- activesupport/test/inflector_test_cases.rb | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/activesupport/lib/active_support/inflector.rb b/activesupport/lib/active_support/inflector.rb index 3ed30bd..71f4c44 100644 --- a/activesupport/lib/active_support/inflector.rb +++ b/activesupport/lib/active_support/inflector.rb @@ -260,7 +260,7 @@ module ActiveSupport # 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. diff --git a/activesupport/test/inflector_test_cases.rb b/activesupport/test/inflector_test_cases.rb index 584cbff..dbd9059 100644 --- a/activesupport/test/inflector_test_cases.rb +++ b/activesupport/test/inflector_test_cases.rb @@ -151,7 +151,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 = { @@ -159,7 +160,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 = { @@ -167,7 +169,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. -- 1.7.0