From adf44426488e92102dc84fa7dcf33b7085de24bf Mon Sep 17 00:00:00 2001 From: Ryan Lue Date: Fri, 11 Oct 2019 17:04:01 +0200 Subject: [PATCH] Fixes #2701 - Can't forward articles containing a tag without src attribute. --- app/assets/javascripts/app/lib/app_post/utils.coffee | 9 ++++++--- public/assets/tests/html_utils.js | 7 +++++++ 2 files changed, 13 insertions(+), 3 deletions(-) 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 = 'foosome test' + should = 'foosome test' + result = App.Utils.htmlImage2DataUrl(source) + equal(result, should, source) + }); test('App.Utils.icon()', function() {