1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-22 16:31:12 +00:00

"attachment:filename" link syntax would not work if the file name contains "@" (#26507).

Patch by Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/trunk@17393 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2018-06-17 05:57:39 +00:00
parent 270b6c4d7e
commit b1b89ff0ac
2 changed files with 20 additions and 0 deletions

View File

@ -180,6 +180,10 @@ module Redmine
html.gsub!(%r{\buser:<a(\sclass="email")? href="mailto:(.*?)">(.*?)<\/a>}) do html.gsub!(%r{\buser:<a(\sclass="email")? href="mailto:(.*?)">(.*?)<\/a>}) do
"user:#{$2}" "user:#{$2}"
end end
# restore attachments links with @ in file name eg. [attachment:image@2x.png]
html.gsub!(%r{\battachment:<a(\sclass="email")? href="mailto:(.*?)">(.*?)</a>}) do
"attachment:#{$2}"
end
html html
end end
end end

View File

@ -694,6 +694,22 @@ RAW
textilizable('attachment:test.txt', :attachments => [a1, a2]) textilizable('attachment:test.txt', :attachments => [a1, a2])
end end
def test_attachment_links_to_images_with_email_format_should_not_be_parsed
attachment = Attachment.generate!(:filename => 'image@2x.png')
with_settings :text_formatting => 'textile' do
raw = "attachment:image@2x.png should not be parsed in image@2x.png"
assert_match %r{<p><a class="attachment" href="/attachments/#{attachment.id}/image@2x.png">image@2x.png</a> should not be parsed in <a class="email" href="mailto:image@2x.png">image@2x.png</a></p>},
textilizable(raw, :attachments => [attachment])
end
with_settings :text_formatting => 'markdown' do
raw = "attachment:image@2x.png should not be parsed in image@2x.png"
assert_match %r{<p><a class="attachment" href="/attachments/#{attachment.id}/image@2x.png">image@2x.png</a> should not be parsed in <a href="mailto:image@2x.png">image@2x.png</a></p>} ,
textilizable(raw, :attachments => [attachment])
end
end
def test_wiki_links def test_wiki_links
User.current = User.find_by_login('jsmith') User.current = User.find_by_login('jsmith')
russian_eacape = CGI.escape(@russian_test) russian_eacape = CGI.escape(@russian_test)