forked from archive/andrewferrier_email2pdf
Fix lowercasing logic.
This commit is contained in:
parent
7ff3cd36a1
commit
dff6c2946c
4 changed files with 18 additions and 4 deletions
|
@ -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:
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -142,6 +142,18 @@ class TestMIME(Email2PDFTestCase):
|
|||
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!")
|
||||
|
|
BIN
tests/UPPERCASE.png
Normal file
BIN
tests/UPPERCASE.png
Normal file
Binary file not shown.
After (image error) Size: 595 B |
Loading…
Reference in a new issue