Patch #27114 ยป make-robust.diff
| lib/redmine/helpers/url.rb | ||
|---|---|---|
| 27 | 27 |
|
| 28 | 28 |
# Other URLs need to be parsed |
| 29 | 29 |
schemes.include? URI.parse(uri).scheme |
| 30 |
rescue URI::InvalidURIError
|
|
| 30 |
rescue URI::Error |
|
| 31 | 31 |
false |
| 32 | 32 |
end |
| 33 | 33 |
end |
| test/unit/lib/redmine/helpers/url_test.rb | ||
|---|---|---|
| 1 |
require File.expand_path('../../../../../test_helper', __FILE__)
|
|
| 2 | ||
| 3 |
class URLTest < ActiveSupport::TestCase |
|
| 4 |
include Redmine::Helpers::URL |
|
| 5 | ||
| 6 |
def test_uri_with_safe_scheme |
|
| 7 |
assert uri_with_safe_scheme?("http://example.com/")
|
|
| 8 |
assert uri_with_safe_scheme?("https://example.com/")
|
|
| 9 |
assert uri_with_safe_scheme?("ftp://example.com/index.html")
|
|
| 10 |
assert uri_with_safe_scheme?("mailto:root@example.com")
|
|
| 11 |
end |
|
| 12 | ||
| 13 |
def test_uri_with_safe_scheme_invalid_component |
|
| 14 |
assert_not uri_with_safe_scheme?("httpx://example.com/")
|
|
| 15 |
assert_not uri_with_safe_scheme?("mailto:root@")
|
|
| 16 |
end |
|
| 17 |
end |
|