From 8afc36400bf5dd94e83cc99f5ce64aeaa21d8cee Mon Sep 17 00:00:00 2001 From: harada Date: Wed, 23 Jan 2019 09:55:44 +0900 Subject: [PATCH 2/2] URL-followed-by-tag --- lib/redmine/wiki_formatting.rb | 2 +- lib/redmine/wiki_formatting/textile/redcloth3.rb | 2 +- test/helpers/application_helper_test.rb | 7 +++++++ .../lib/redmine/wiki_formatting/textile_formatter_test.rb | 6 ++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index 66764551d..8bd8f64bc 100644 --- a/lib/redmine/wiki_formatting.rb +++ b/lib/redmine/wiki_formatting.rb @@ -126,7 +126,7 @@ module Redmine (\/)? # slash ) ((?:>)?|[^[:alnum:]_\=\/;\(\)]*?) # post - (?=<|\s|$) + (?=<|<|\s|$) }x unless const_defined?(:AUTO_LINK_RE) # Destructively replaces urls into clickable links diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb index 9107da611..ff0621b9f 100644 --- a/lib/redmine/wiki_formatting/textile/redcloth3.rb +++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb @@ -830,7 +830,7 @@ class RedCloth3 < String (\/)? # $slash ([^[:alnum:]_\=\/;\(\)]*?) # $post ) - (?=<|\s|$) + (?=<|<|\s|$) /x #" def inline_textile_link( text ) diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 5561e2f40..6aa8c576b 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -282,6 +282,13 @@ RAW to_test.each { |text, result| assert_equal "

#{result}

", textilizable(text) } end + def test_textile_external_links_with_followed_by_tag + to_test = { + '"test":http://foo/bar<baz>' => 'test<baz>', + } + to_test.each { |text, result| assert_equal "

#{result}

", textilizable(text) } + end + def test_redmine_links user_with_email_login = User.generate!(:login => 'abcd@example.com') user_with_email_login_2 = User.generate!(:login => 'foo.bar@example.com') diff --git a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb index 97912cbdf..79c8c4f08 100644 --- a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb @@ -621,6 +621,12 @@ EXPECTED assert_equal expected.gsub(%r{[\r\n\t]}, ''), to_html(text).gsub(%r{[\r\n\t]}, '') end + def test_should_link_url_with_followed_by_tag + assert_html_output({ + 'http://www.redmine.org/example<foo>' => 'http://www.redmine.org/example<foo>', + }) + end + private def assert_html_output(to_test, expect_paragraph = true) -- 2.20.1