diff --git a/app/assets/javascripts/app/lib/app_post/utils.coffee b/app/assets/javascripts/app/lib/app_post/utils.coffee
index 4efc203b1..5a80d973c 100644
--- a/app/assets/javascripts/app/lib/app_post/utils.coffee
+++ b/app/assets/javascripts/app/lib/app_post/utils.coffee
@@ -1205,9 +1205,12 @@ class App.Utils
html.find('img').each( (index) ->
src = $(@).attr('src')
- if !src.match(/^(data|cid):/i) # may mean broken emails (see issue #2305)
- base64 = App.Utils._htmlImage2DataUrl(@)
- $(@).attr('src', base64)
+
+ # or an empty src attribute may mean broken emails (see issue #2305 / #2701)
+ return if !src? or src.match(/^(data|cid):/i)
+
+ base64 = App.Utils._htmlImage2DataUrl(@)
+ $(@).attr('src', base64)
)
html.get(0).innerHTML
diff --git a/public/assets/tests/html_utils.js b/public/assets/tests/html_utils.js
index 36edadca4..a409a1674 100644
--- a/public/assets/tests/html_utils.js
+++ b/public/assets/tests/html_utils.js
@@ -3167,11 +3167,18 @@ test("htmlImage2DataUrl", function() {
result = App.Utils.htmlImage2DataUrl(source)
equal(result, should, source)
+ // GitHub issue #2305
source = 'some test'
should = 'some test'
result = App.Utils.htmlImage2DataUrl(source)
equal(result, should, source)
+ // GitHub issue #2701
+ source = 'some test'
+ should = 'some test'
+ result = App.Utils.htmlImage2DataUrl(source)
+ equal(result, should, source)
+
});
test('App.Utils.icon()', function() {