Commit 5e5e5766 authored by maeda's avatar maeda

Make robust Redmine::Helpers::URL#uri_with_safe_scheme? (#27114)

Patch by okkez.


git-svn-id: https://svn.redmine.org/redmine/trunk@17035 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent ee2e9a3d
......@@ -27,7 +27,7 @@ module Redmine
# Other URLs need to be parsed
schemes.include? URI.parse(uri).scheme
rescue URI::InvalidURIError
rescue URI::Error
false
end
end
......
require File.expand_path('../../../../../test_helper', __FILE__)
class URLTest < ActiveSupport::TestCase
include Redmine::Helpers::URL
def test_uri_with_safe_scheme
assert uri_with_safe_scheme?("http://example.com/")
assert uri_with_safe_scheme?("https://example.com/")
assert uri_with_safe_scheme?("ftp://example.com/index.html")
assert uri_with_safe_scheme?("mailto:root@example.com")
end
def test_uri_with_safe_scheme_invalid_component
assert_not uri_with_safe_scheme?("httpx://example.com/")
assert_not uri_with_safe_scheme?("mailto:root@")
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment