Skip to content
This repository has been archived by the owner on Dec 11, 2021. It is now read-only.

Commit

Permalink
Fix lowercasing logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Ferrier committed Mar 16, 2015
1 parent 7ff3cd3 commit dff6c29
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
9 changes: 5 additions & 4 deletions email2pdf
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions tests/BaseTestClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"
Expand Down
12 changes: 12 additions & 0 deletions tests/Subprocess/test_Subprocess_MIME.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('<img src="' + self.EXIST_IMG_UPPERCASE + '">')
(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!")
Expand Down
Binary file added tests/UPPERCASE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dff6c29

Please sign in to comment.