From f748296121db2fe7dbaab87a2275f096f5860cb7 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 17 Jun 2018 06:00:21 +0000 Subject: [PATCH] Image filename for HDPI monitors (image@2x.jpg) are misrecognized as email address (#27968). Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@17394 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- 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 412d0f434..f4496d98f 100644 --- 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 b90522d81..34e4fe119 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -699,13 +699,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 f6bf2d3f6..b460bad35 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