Project

General

Profile

Defect #26507 » 26507_fix_attachment_links_with_@_in_file_name.patch

Marius BĂLTEANU, 2018-04-08 09:26

View differences:

lib/redmine/wiki_formatting.rb
html.gsub!(%r{\buser:<a(\sclass="email")? href="mailto:(.*?)">(.*?)<\/a>}) do
"user:#{$2}"
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
end
end
test/helpers/application_helper_test.rb
textilizable('attachment:test.txt', :attachments => [a1, a2])
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
User.current = User.find_by_login('jsmith')
russian_eacape = CGI.escape(@russian_test)
(2-2/2)