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