Fixed that autolinks and textile links ending with cyrilic characters are broken (#12397).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10879 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-11-24 14:20:01 +00:00
parent b94c971755
commit fb9a2901e9
3 changed files with 25 additions and 3 deletions

View File

@ -816,10 +816,10 @@ class RedCloth3 < String
":
( # $url
(\/|[a-zA-Z]+:\/\/|www\.|mailto:) # $proto
[\w\/]\S+?
[[:alnum:]_\/]\S+?
)
(\/)? # $slash
([^\w\=\/;\(\)]*?) # $post
([^[:alnum:]_\=\/;\(\)]*?) # $post
)
(?=<|\s|$)
/x

View File

@ -98,7 +98,7 @@ module Redmine
(\S+?) # url
(\/)? # slash
)
((?:&gt;)?|[^\w\=\/;\(\)]*?) # post
((?:&gt;)?|[^[:alnum:]_\=\/;\(\)]*?) # post
(?=<|\s|$)
}x unless const_defined?(:AUTO_LINK_RE)

View File

@ -88,6 +88,17 @@ class ApplicationHelperTest < ActionView::TestCase
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
end
if 'ruby'.respond_to?(:encoding)
def test_auto_links_with_non_ascii_characters
to_test = {
'http://foo.bar/тест' => '<a class="external" href="http://foo.bar/тест">http://foo.bar/тест</a>'
}
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
end
else
puts 'Skipping test_auto_links_with_non_ascii_characters, unsupported ruby version'
end
def test_auto_mailto
assert_equal '<p><a class="email" href="mailto:test@foo.bar">test@foo.bar</a></p>',
textilizable('test@foo.bar')
@ -228,6 +239,17 @@ RAW
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
end
if 'ruby'.respond_to?(:encoding)
def test_textile_external_links_with_non_ascii_characters
to_test = {
'This is a "link":http://foo.bar/тест' => 'This is a <a href="http://foo.bar/тест" class="external">link</a>'
}
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
end
else
puts 'Skipping test_textile_external_links_with_non_ascii_characters, unsupported ruby version'
end
def test_redmine_links
issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3},
:class => 'issue status-1 priority-4 priority-lowest overdue', :title => 'Error 281 when updating a recipe (New)')