Skip to content

Commit

Permalink
FilterParameter#hash_to_params: do not escape backslash. Fixes #74.
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan authored and Sija committed Aug 20, 2012
1 parent 59701f4 commit dcaf227
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/garb/filter_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def hash_to_params(hsh)
hsh.map do |k, v|
next unless k.is_a?(SymbolOperatorMethods)

escaped_v = v.to_s.gsub(/([,;\\])/) { |c| '\\' + c }
escaped_v = v.to_s.gsub(/([,;])/) { |c| '\\' + c }
"#{URI.encode(k.to_google_analytics, /[=<>]/)}#{CGI::escape(escaped_v)}"
end.join('%3B') # Hash AND (no duplicate keys), escape char for ';' fixes oauth
end
Expand Down
4 changes: 2 additions & 2 deletions test/unit/garb/filter_parameters_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class FilterParametersTest < MiniTest::Unit::TestCase
assert_equal params, filters.to_params
end

should "escape comma, semicolon, and backslash in values" do
should "escape comma, semicolon in values" do
filters = FilterParameters.new({:url.eql => 'this;that,thing\other'})

params = {'filters' => 'ga:url%3D%3Dthis%5C%3Bthat%5C%2Cthing%5C%5Cother'}
params = {'filters' => 'ga:url%3D%3Dthis%5C%3Bthat%5C%2Cthing%5Cother'}
assert_equal params, filters.to_params
end

Expand Down

0 comments on commit dcaf227

Please sign in to comment.