Project

General

Profile

Defect #30259 » 0002-Interpret-trailing-hyphens-as-URL.patch

Yuichi HARADA, 2019-01-08 09:07

View differences:

lib/redmine/wiki_formatting.rb
([^<]\S*?) # url
(\/)? # slash
)
((?:&gt;)?|[^[:alnum:]_\=\/;\(\)]*?) # post
((?:&gt;)?|[^[:alnum:]_\=\/;\(\)\-]*?) # post
(?=<|\s|$)
}x unless const_defined?(:AUTO_LINK_RE)
lib/redmine/wiki_formatting/textile/redcloth3.rb
@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]
textile_rules = [:block_textile_table, :block_textile_lists, :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]
......
[[:alnum:]_\/]\S+?
)
(\/)? # $slash
([^[:alnum:]_\=\/;\(\)]*?) # $post
([^[:alnum:]_\=\/;\(\)\-]*?) # $post
)
(?=<|\s|$)
/x
test/helpers/application_helper_test.rb
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
end
def test_textile_links_with_hyphens
to_test = {
'(see "inline link":http://www.foo.bar/Test-)' => '(see <a href="http://www.foo.bar/Test-" class="external">inline link</a>)',
'http://foo.bar/page?p=1&t=z&s=-' => '<a class="external" href="http://foo.bar/page?p=1&#38;t=z&#38;s=-">http://foo.bar/page?p=1&#38;t=z&#38;s=-</a>',
'This is an intern "link":/foo/bar-' => 'This is an intern <a href="/foo/bar-">link</a>',
}
to_test.each { |text, result| assert_equal "<p>#{result}</p>", 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')
test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
assert_equal expected.gsub(%r{[\r\n\t]}, ''), to_html(text).gsub(%r{[\r\n\t]}, '')
end
def test_should_link_url_with_hyphens
assert_html_output({
'http://www.redmine.org/example-' => '<a class="external" href="http://www.redmine.org/example-">http://www.redmine.org/example-</a>'
})
end
private
def assert_html_output(to_test, expect_paragraph = true)
(3-3/4)