From c379353553f5383461e07a21b2278b8281420154 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Mon, 28 Dec 2015 14:59:07 -0800 Subject: [PATCH] fix(autoload-images): Watch for images declared in more attrs Fixes #739 --- .../lib/autoload-images-store.coffee | 8 ++++++-- .../spec/fixtures/table-body-in.html | 1 + .../spec/fixtures/table-body-out.html | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 internal_packages/message-autoload-images/spec/fixtures/table-body-in.html create mode 100644 internal_packages/message-autoload-images/spec/fixtures/table-body-out.html diff --git a/internal_packages/message-autoload-images/lib/autoload-images-store.coffee b/internal_packages/message-autoload-images/lib/autoload-images-store.coffee index c8d66395a..a3da9cf29 100644 --- a/internal_packages/message-autoload-images/lib/autoload-images-store.coffee +++ b/internal_packages/message-autoload-images/lib/autoload-images-store.coffee @@ -4,8 +4,12 @@ path = require 'path' {Utils, MessageBodyProcessor} = require 'nylas-exports' AutoloadImagesActions = require './autoload-images-actions' -# https://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support -ImagesRegexp = /(src[\s]*=[\s]*['"]+|:[\s]*url\()+([^"'\)]*)/gi +# Match: +# - any of the DOM attributes supporting images starting with a protocol +# (src, background, placeholder, icon, poster, or srcset) +# - any url() value +# +ImagesRegexp = /((?:src|background|placeholder|icon|background|poster|srcset)\s*=\s*['"]?(?=\w*:\/\/)|:\s*url\()+([^"'\)]*)/gi class AutoloadImagesStore extends NylasStore constructor: -> diff --git a/internal_packages/message-autoload-images/spec/fixtures/table-body-in.html b/internal_packages/message-autoload-images/spec/fixtures/table-body-in.html new file mode 100644 index 000000000..286220c72 --- /dev/null +++ b/internal_packages/message-autoload-images/spec/fixtures/table-body-in.html @@ -0,0 +1 @@ + diff --git a/internal_packages/message-autoload-images/spec/fixtures/table-body-out.html b/internal_packages/message-autoload-images/spec/fixtures/table-body-out.html new file mode 100644 index 000000000..88a69513c --- /dev/null +++ b/internal_packages/message-autoload-images/spec/fixtures/table-body-out.html @@ -0,0 +1 @@ +