From dff6c2946c95de3a51ac6e9691850776a7305505 Mon Sep 17 00:00:00 2001 From: Andrew Ferrier Date: Mon, 16 Mar 2015 23:48:44 +0000 Subject: [PATCH] Fix lowercasing logic. --- email2pdf | 9 +++++---- tests/BaseTestClasses.py | 1 + tests/Subprocess/test_Subprocess_MIME.py | 12 ++++++++++++ tests/UPPERCASE.png | Bin 0 -> 595 bytes 4 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 tests/UPPERCASE.png 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 0000000000000000000000000000000000000000..cd7e50f91402240a419ba4792d52f6f481d46afa GIT binary patch literal 595 zcmV-Z0<8UsP)v}5QRU_7&y#fp@D&gr9M`8f1y92FoiBVSa`IsurPtS ze{e7d3sdH>SD>hoE4z_nx$z0??7UgMea|aJNhAr@Zvg8Z*gUmKePu;z>y8jWkvlsq z1W-(qZPlsA;>PQ-xbb>e=+HyjR`72RpJL@9duyYiw{L8ondoV1Dstk)`yNe2E|Tn) zQn&|5Z4$O-o8S$zjgb_v!ImC3RAHrGc4#Vv!)L8;XfO3ToGLXjk#F*79m4!RxgIe_tfnTuJcqEWy)4g2yKb%DDu0za_YxN$~Sgf+CmT>X!ubOoF_W z03=B5#`sg62L3e6{2RJyFI>13c>MtF{pl)#xkJ@t(o7&`wRIOmYhI*_#{U5rtXn@HNfb7oz6Bu5!i$}Tx-z(a!?=gYPiFWah6BvhR7Y~@g_(Z#S%LK+P h+Qpp-{6C^y{2ine-m~8mME3vy002ovPDHLkV1lO|5~BbB literal 0 HcmV?d00001