Defect #27968 » 0001-do-not-recognize-hires-images-as-email-addresses.patch
| lib/redmine/wiki_formatting.rb | ||
|---|---|---|
|
html.gsub!(%r{\battachment:<a(\sclass="email")? href="mailto:(.*?)">(.*?)</a>}) do
|
||
|
"attachment:#{$2}"
|
||
|
end
|
||
|
# restore hires images which are misrecognized as email address eg. [printscreen@2x.png]
|
||
|
html.gsub!(%r{<a(\sclass="email")? href="mailto:[^"]+@\dx\.(bmp|gif|jpg|jpe|jpeg|png)">(.*?)</a>}) do
|
||
|
"#{$3}"
|
||
|
end
|
||
|
html
|
||
|
end
|
||
|
end
|
||
| test/helpers/application_helper_test.rb | ||
|---|---|---|
|
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>},
|
||
|
assert_match %r{<p><a class="attachment" href="/attachments/#{attachment.id}/image@2x.png">image@2x.png</a> should not be parsed in image@2x.png</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>} ,
|
||
|
assert_match %r{<p><a class="attachment" href="/attachments/#{attachment.id}/image@2x.png">image@2x.png</a> should not be parsed in image@2x.png</p>} ,
|
||
|
textilizable(raw, :attachments => [attachment])
|
||
|
end
|
||
|
end
|
||
| test/unit/lib/redmine/wiki_formatting_test.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
def test_hires_images_should_not_be_recognized_as_email_addresses
|
||
|
raw = <<-DIFF
|
||
|
Image: logo@2x.png
|
||
|
DIFF
|
||
|
expected = <<-EXPECTED
|
||
|
<p>Image: logo@2x.png</p>
|
||
|
EXPECTED
|
||
|
assert_equal expected.gsub(%r{[\r\n\t]}, ''), Redmine::WikiFormatting::NullFormatter::Formatter.new(raw).to_html.gsub(%r{[\r\n\t]}, '')
|
||
|
end
|
||
|
def test_cache_key_for_saved_object_should_no_be_nil
|
||
|
assert_not_nil Redmine::WikiFormatting.cache_key_for('textile', 'Text', Issue.find(1), :description)
|
||
|
end
|
||