diff --git a/email2pdf b/email2pdf index 5493b82..320afa2 100755 --- a/email2pdf +++ b/email2pdf @@ -255,14 +255,15 @@ def remove_invalid_urls(payload): for img in soup.find_all('img'): if img.has_attr('src'): - src = img['src'].lower() - if src == 'broken': + src = img['src'] + lowerSrc = src.lower() + if lowerSrc == 'broken': del img['src'] - elif not (src.startswith('data')): + elif not (lowerSrc.startswith('data')): foundBlacklist = False for IMAGE_LOAD_BLACKLIST_ITEM in IMAGE_LOAD_BLACKLIST: - if IMAGE_LOAD_BLACKLIST_ITEM in src: + if IMAGE_LOAD_BLACKLIST_ITEM in lowerSrc: foundBlacklist = True if not foundBlacklist: diff --git a/tests/BaseTestClasses.py b/tests/BaseTestClasses.py index 435e35e..acce041 100644 --- a/tests/BaseTestClasses.py +++ b/tests/BaseTestClasses.py @@ -33,6 +33,7 @@ class Email2PDFTestCase(unittest.TestCase): NONEXIST_IMG = 'http://www.andrewferrier.com/nonexist.jpg' NONEXIST_IMG_BLACKLIST = 'http://www.emltrk.com/nonexist.jpg' EXIST_IMG = 'https://raw.githubusercontent.com/andrewferrier/email2pdf/master/tests/basi2c16.png' + EXIST_IMG_UPPERCASE = 'https://raw.githubusercontent.com/andrewferrier/email2pdf/master/tests/UPPERCASE.png' COMMAND = os.path.normpath(os.path.join(os.getcwd(), 'email2pdf')) DEFAULT_FROM = "from@example.org" diff --git a/tests/Subprocess/test_Subprocess_MIME.py b/tests/Subprocess/test_Subprocess_MIME.py index 0fc7f79..35baf41 100644 --- a/tests/Subprocess/test_Subprocess_MIME.py +++ b/tests/Subprocess/test_Subprocess_MIME.py @@ -142,6 +142,18 @@ def test_remote_image_does_exist(self): else: self.skipTest("Not online.") + def test_remote_image_does_exist_uppercase(self): + if self.isOnline: + path = os.path.join(self.examineDir, "remoteImageDoesExistUppercase.pdf") + self.addHeaders() + self.attachHTML('') + (rc, output, error) = self.invokeAsSubprocess(outputFile=path) + self.assertEqual(0, rc) + self.assertEqual('', error) + self.assertTrue(os.path.exists(path)) + else: + self.skipTest("Not online.") + def test_non_embedded_image_jpeg(self): self.addHeaders() self.attachText("Hello!") diff --git a/tests/UPPERCASE.png b/tests/UPPERCASE.png new file mode 100644 index 0000000..cd7e50f Binary files /dev/null and b/tests/UPPERCASE.png differ