Skip to content

Commit

Permalink
Fix #2312
Browse files Browse the repository at this point in the history
  • Loading branch information
tdreyno committed Sep 15, 2020
1 parent 5340641 commit 7c155c2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion middleman-core/lib/middleman-core/rack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'rack/lint'
require 'rack/head'
require 'rack/utils'
require 'webrick'

require 'middleman-core/util'
require 'middleman-core/logger'
Expand Down Expand Up @@ -86,7 +87,7 @@ def halt(response)
def process_request(env, req, res)
start_time = Time.now

request_path = URI.decode(env['PATH_INFO'].dup)
request_path = WEBrick::HTTPUtils.unescape(env['PATH_INFO'].dup)
if request_path.respond_to? :force_encoding
request_path.force_encoding('UTF-8')
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'middleman-core/rack'
require 'rspec/expectations'
require 'capybara/cucumber'
require 'webrick'

Given /^a clean server$/ do
@initialize_commands = []
Expand Down Expand Up @@ -72,11 +73,11 @@
end

When /^I go to "([^\"]*)"$/ do |url|
visit(URI.encode(url).to_s)
visit(WEBrick::HTTPUtils.escape(url))
end

Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
expect{ visit(URI.encode(url).to_s) }.to_not raise_exception
expect{ visit(WEBrick::HTTPUtils.escape(url)) }.to_not raise_exception
end

Then /^the content type should be "([^\"]*)"$/ do |expected|
Expand Down
3 changes: 2 additions & 1 deletion middleman-core/lib/middleman-core/util/paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'addressable/uri'
require 'memoist'
require 'tilt'
require 'webrick'

require 'middleman-core/contracts'

Expand Down Expand Up @@ -33,7 +34,7 @@ def tilt_class(path)
Contract String => String
def normalize_path(path)
# The tr call works around a bug in Ruby's Unicode handling
::URI.decode(path).sub(%r{^/}, '').tr('', '')
WEBrick::HTTPUtils.unescape(path).sub(%r{^/}, '').tr('', '')
end
memoize :normalize_path

Expand Down

0 comments on commit 7c155c2

Please sign in to comment.