From 193b02567b1d889324d8709547b135e14f80d837 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sun, 3 Mar 2019 15:18:04 +0000 Subject: [PATCH] URLs end with "-" are rendered incorrectly in Textile (#30259). Patch by Yuichi HARADA. git-svn-id: http://svn.redmine.org/redmine/trunk@17917 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/wiki_formatting.rb | 2 +- lib/redmine/wiki_formatting/textile/redcloth3.rb | 6 +++--- test/helpers/application_helper_test.rb | 7 ++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index 66764551d..d4dd05a93 100644 --- a/lib/redmine/wiki_formatting.rb +++ b/lib/redmine/wiki_formatting.rb @@ -125,7 +125,7 @@ module Redmine ([^<]\S*?) # url (\/)? # slash ) - ((?:>)?|[^[:alnum:]_\=\/;\(\)]*?) # post + ((?:>)?|[^[:alnum:]_\=\/;\(\)\-]*?) # post (?=<|\s|$) }x unless const_defined?(:AUTO_LINK_RE) diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb index 5fbfc4338..5da17be5b 100644 --- a/lib/redmine/wiki_formatting/textile/redcloth3.rb +++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb @@ -272,8 +272,8 @@ class RedCloth3 < String @urlrefs = {} @shelf = [] textile_rules = [:block_textile_table, :block_textile_lists, - :block_textile_prefix, :inline_textile_image, :inline_textile_link, - :inline_textile_code, :inline_textile_span, :glyphs_textile] + :block_textile_prefix, :inline_textile_image, :inline_textile_code, + :inline_textile_span, :inline_textile_link, :glyphs_textile] markdown_rules = [:refs_markdown, :block_markdown_setext, :block_markdown_atx, :block_markdown_rule, :block_markdown_bq, :block_markdown_lists, :inline_markdown_reflink, :inline_markdown_link] @@ -829,7 +829,7 @@ class RedCloth3 < String [[:alnum:]_\/]\S+? ) (\/)? # $slash - ([^[:alnum:]_\=\/;\(\)]*?) # $post + ([^[:alnum:]_\=\/;\(\)\-]*?) # $post ) (?=<|\s|$) /x diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 26ca772b7..bfefc1052 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -94,6 +94,8 @@ class ApplicationHelperTest < Redmine::HelperTest 'http://' => 'http://', 'www.' => 'www.', 'test-www.bar.com' => 'test-www.bar.com', + # ends with a hyphen + 'http://www.redmine.org/example-' => 'http://www.redmine.org/example-', } to_test.each { |text, result| assert_equal "

#{result}

", textilizable(text) } end @@ -270,7 +272,10 @@ RAW '"a link":http://example.net/path!602815048C7B5C20!302.html' => 'a link', # escaping '"test":http://foo"bar' => 'test', - } + # ends with a hyphen + '(see "inline link":http://www.foo.bar/Test-)' => '(see inline link)', + 'http://foo.bar/page?p=1&t=z&s=-' => 'http://foo.bar/page?p=1&t=z&s=-', + 'This is an intern "link":/foo/bar-' => 'This is an intern link', } to_test.each { |text, result| assert_equal "

#{result}

", textilizable(text) } end