From 1b216ff67ed6d5b5ee8725315fb9fa9c556a7c34 Mon Sep 17 00:00:00 2001 From: Marius BALTEANU Date: Sun, 29 Apr 2018 07:01:05 +0000 Subject: [PATCH] do not recognize hires images as email addresses --- lib/redmine/wiki_formatting.rb | 4 ++++ test/helpers/application_helper_test.rb | 4 ++-- test/unit/lib/redmine/wiki_formatting_test.rb | 12 ++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index 412d0f4..f4496d9 100755 --- a/lib/redmine/wiki_formatting.rb +++ b/lib/redmine/wiki_formatting.rb @@ -184,6 +184,10 @@ module Redmine html.gsub!(%r{\battachment:(.*?)}) do "attachment:#{$2}" end + # restore hires images which are misrecognized as email address eg. [printscreen@2x.png] + html.gsub!(%r{(.*?)}) do + "#{$3}" + end html end end diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 3887660..07827a2 100755 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -697,13 +697,13 @@ RAW with_settings :text_formatting => 'textile' do raw = "attachment:image@2x.png should not be parsed in image@2x.png" - assert_match %r{

image@2x.png should not be parsed in

}, + assert_match %r{

image@2x.png should not be parsed in image@2x.png

}, 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{

image@2x.png should not be parsed in image@2x.png

} , + assert_match %r{

image@2x.png should not be parsed in image@2x.png

} , textilizable(raw, :attachments => [attachment]) end end diff --git a/test/unit/lib/redmine/wiki_formatting_test.rb b/test/unit/lib/redmine/wiki_formatting_test.rb index f6bf2d3..b460bad 100644 --- a/test/unit/lib/redmine/wiki_formatting_test.rb +++ b/test/unit/lib/redmine/wiki_formatting_test.rb @@ -77,6 +77,18 @@ EXPECTED end end + def test_hires_images_should_not_be_recognized_as_email_addresses + raw = <<-DIFF +Image: logo@2x.png + DIFF + + expected = <<-EXPECTED +

Image: logo@2x.png

+ 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 -- 2.1.4