Project

General

Profile

Defect #19735 ยป allow-slashes-in-local-part.diff

patch to fix this - Go MAEDA, 2015-04-29 05:43

View differences:

lib/redmine/wiki_formatting.rb (working copy)
# Destructively replaces email addresses into clickable links
def auto_mailto!(text)
text.gsub!(/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do
text.gsub!(/([\w\.!#\$%\-+.\/]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do
mail = $1
if text.match(/<a\b[^>]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/)
mail
test/unit/lib/redmine/wiki_formatting_test.rb (working copy)
def test_should_link_urls_and_email_addresses
raw = <<-DIFF
This is a sample *text* with a link: http://www.redmine.org
and an email address foo@example.net
and email addresses foo@example.net and foo/bar@example.net
DIFF
expected = <<-EXPECTED
<p>This is a sample *text* with a link: <a class="external" href="http://www.redmine.org">http://www.redmine.org</a><br />
and an email address <a class="email" href="mailto:foo@example.net">foo@example.net</a></p>
and email addresses <a class="email" href="mailto:foo@example.net">foo@example.net</a> and <a class="email" href="mailto:foo/bar@example.net">foo/bar@example.net</a></p>
EXPECTED
assert_equal expected.gsub(%r{[\r\n\t]}, ''), Redmine::WikiFormatting::NullFormatter::Formatter.new(raw).to_html.gsub(%r{[\r\n\t]}, '')
    (1-1/1)