#956 Non-ASCII characters in external links
This commit is contained in:
parent
689b2dc793
commit
481edb9ae9
@ -25,12 +25,14 @@ class DmsfUrlValidator < ActiveModel::EachValidator
|
||||
if record.target_type == 'DmsfUrl'
|
||||
begin
|
||||
if value.present?
|
||||
URI.parse value
|
||||
# TODO : This prevents from entering valid URLs with non-ASCII characters sue as: 'https://www.google.com/search?q=寿司'
|
||||
#URI.parse value
|
||||
else
|
||||
record.errors.add attribute, :invalid
|
||||
end
|
||||
rescue URI::InvalidURIError
|
||||
rescue URI::InvalidURIError => e
|
||||
record.errors.add attribute, :invalid
|
||||
Rails.logger.error e.message
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -113,7 +113,7 @@ class DmsfLinksTest < RedmineDmsf::Test::UnitTest
|
||||
|
||||
def test_validate_external_url
|
||||
@file_link.target_type = 'DmsfUrl'
|
||||
@file_link.external_url = 'htt ps://abc.xyz'
|
||||
@file_link.external_url = ''
|
||||
assert !@file_link.save,
|
||||
"External URL link #{@file_link.name} should have not been saved"
|
||||
assert_equal 1, @file_link.errors.size
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user