From c2234d74565b98c7876da685ba2bac745b2819f0 Mon Sep 17 00:00:00 2001 From: Jens Pfeifer Date: Thu, 13 Jul 2017 09:59:22 +0000 Subject: [PATCH] Fixed issue #1230, missing backslashes in body of sent emails. --- app/models/channel/email_build.rb | 4 +++- test/unit/email_build_test.rb | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/channel/email_build.rb b/app/models/channel/email_build.rb index 3629bfe3a..034d5783d 100644 --- a/app/models/channel/email_build.rb +++ b/app/models/channel/email_build.rb @@ -156,7 +156,9 @@ Check if string is a complete html document. If not, add head and css styles. return html if html =~ //i - Rails.configuration.html_email_body.sub('###html###', html) + # use block form because variable html could contain backslashes and e. g. '\1' that + # must not be handled as back-references for regular expressions + Rails.configuration.html_email_body.sub('###html###') {html} end =begin diff --git a/test/unit/email_build_test.rb b/test/unit/email_build_test.rb index 7e2d3410e..8d161ea5b 100644 --- a/test/unit/email_build_test.rb +++ b/test/unit/email_build_test.rb @@ -22,6 +22,12 @@ class EmailBuildTest < ActiveSupport::TestCase assert(result !~ /font-family/, 'test 2') assert(result =~ %r{test}, 'test 2') + # Issue #1230, missing backslashes + # 'Test URL: \\storage\project\100242-Inc' + html = 'Test URL: \\\\storage\\project\\100242-Inc' + result = Channel::EmailBuild.html_complete_check(html) + assert(result.include?(html), 'backslashes must be kept') + end test 'html email + attachment check' do