Try to encode URI before parsing so spaces in paths work. Fixes #1914
This commit is contained in:
parent
6440d53e7a
commit
4ffaa9dde5
|
@ -40,19 +40,29 @@ Feature: link_to helper
|
||||||
"""
|
"""
|
||||||
absolute: <%= link_to "Needs Index", "/needs_index.html", relative: true %>
|
absolute: <%= link_to "Needs Index", "/needs_index.html", relative: true %>
|
||||||
relative: <%= link_to "Relative", "needs_index.html", relative: true %>
|
relative: <%= link_to "Relative", "needs_index.html", relative: true %>
|
||||||
|
|
||||||
|
absolute spaces: <%= link_to "Spaces Index", "/evil spaces.html", relative: true %>
|
||||||
|
relative spaces: <%= link_to "Spaces Relative", "evil spaces.html", relative: true %>
|
||||||
"""
|
"""
|
||||||
And a file named "source/link_to/sub.html.erb" with:
|
And a file named "source/link_to/sub.html.erb" with:
|
||||||
"""
|
"""
|
||||||
absolute: <%= link_to "Needs Index", "/needs_index.html", relative: true %>
|
absolute: <%= link_to "Needs Index", "/needs_index.html", relative: true %>
|
||||||
relative: <%= link_to "Relative", "../needs_index.html", relative: true %>
|
relative: <%= link_to "Relative", "../needs_index.html", relative: true %>
|
||||||
|
|
||||||
|
absolute spaces: <%= link_to "Spaces Index", "/evil spaces.html", relative: true %>
|
||||||
|
relative spaces: <%= link_to "Spaces Relative", "../evil spaces.html", relative: true %>
|
||||||
"""
|
"""
|
||||||
And the Server is running at "indexable-app"
|
And the Server is running at "indexable-app"
|
||||||
When I go to "/link_to.html"
|
When I go to "/link_to.html"
|
||||||
Then I should see 'absolute: <a href="needs_index.html">Needs Index</a>'
|
Then I should see 'absolute: <a href="needs_index.html">Needs Index</a>'
|
||||||
Then I should see 'relative: <a href="needs_index.html">Relative</a>'
|
Then I should see 'relative: <a href="needs_index.html">Relative</a>'
|
||||||
|
Then I should see 'absolute spaces: <a href="evil%20spaces.html">Spaces Index</a>'
|
||||||
|
Then I should see 'relative spaces: <a href="evil%20spaces.html">Spaces Relative</a>'
|
||||||
When I go to "/link_to/sub.html"
|
When I go to "/link_to/sub.html"
|
||||||
Then I should see 'absolute: <a href="../needs_index.html">Needs Index</a>'
|
Then I should see 'absolute: <a href="../needs_index.html">Needs Index</a>'
|
||||||
Then I should see 'relative: <a href="../needs_index.html">Relative</a>'
|
Then I should see 'relative: <a href="../needs_index.html">Relative</a>'
|
||||||
|
Then I should see 'absolute spaces: <a href="../evil%20spaces.html">Spaces Index</a>'
|
||||||
|
Then I should see 'relative spaces: <a href="../evil%20spaces.html">Spaces Relative</a>'
|
||||||
|
|
||||||
Scenario: link_to relative works with strip_index_file
|
Scenario: link_to relative works with strip_index_file
|
||||||
Given a fixture app "indexable-app"
|
Given a fixture app "indexable-app"
|
||||||
|
|
|
@ -158,7 +158,7 @@ module Middleman
|
||||||
|
|
||||||
# Try to parse URL
|
# Try to parse URL
|
||||||
begin
|
begin
|
||||||
uri = URI(url)
|
uri = URI(::URI.encode(url))
|
||||||
rescue ::URI::InvalidURIError
|
rescue ::URI::InvalidURIError
|
||||||
# Nothing we can do with it, it's not really a URI
|
# Nothing we can do with it, it's not really a URI
|
||||||
return url
|
return url
|
||||||
|
|
Loading…
Reference in a new issue