Permalink
Browse files

Actually revert changes to encoding that were backported

I don't know what happened when I reverted this but the revert in the
previous commit didn't revert everything which caused Ruby 1.9.3 to not
be correct and the test to be incorrect.

This restores the previous behavior that was expected before this test
changed what it though the expectations of Rack were. Requests that have
incorrect encoding should return a `:bad_request` and not `:ok` or
`:redirect` or `:not_found`.
  • Loading branch information...
eileencodes committed Aug 2, 2017
1 parent e69b7e7 commit 47f8eb928559d3b0c26942d36459cfddea2c12b4
@@ -13,13 +13,11 @@ class Utils # :nodoc:
# normalize_path("") # => "/"
# normalize_path("/%ab") # => "/%AB"
def self.normalize_path(path)
encoding = path.encoding
path = "/#{path}"
path.squeeze!('/')
path.sub!(%r{/+\Z}, '')
path.gsub!(/(%[a-f0-9]{2})/) { $1.upcase }
path = "/" if path == "".freeze
path.force_encoding(encoding)
path = '/' if path == ''
path
end
@@ -4206,16 +4206,16 @@ def show
end
get "/%E2%EF%BF%BD%A6"
assert_response :not_found
assert_response :bad_request
get "/foo/%E2%EF%BF%BD%A6"
assert_response :not_found
assert_response :bad_request
get "/foo/show/%E2%EF%BF%BD%A6"
assert_response :ok
assert_response :bad_request
get "/bar/%E2%EF%BF%BD%A6"
assert_response :redirect
assert_response :bad_request
end
end
end

0 comments on commit 47f8eb9

Please sign in to comment.