Skip to content

Commit

Permalink
Merge pull request #15 from wahlflo/14-diff-output-by-diff-run-with-s…
Browse files Browse the repository at this point in the history
…ame-file-with-same-para

14 diff output by diff run with same file with same para
  • Loading branch information
wahlflo committed Apr 6, 2023
2 parents 9e15f23 + 12c316e commit e163290
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
9 changes: 4 additions & 5 deletions eml_analyzer/library/parser/parsed_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ def _get_decoded_payload_from_message(message: email.message.Message) -> None or
raise PayloadDecodingException('Payload could not be decoded')

@staticmethod
def _create_list_of_possible_encodings(message: email.message.Message) -> set:
def _create_list_of_possible_encodings(message: email.message.Message) -> list:
""" creates a list of the most possible encodings of a payload """
list_of_possible_encodings = set()
list_of_possible_encodings = list()

# at first add the encodings mentioned in the object header
for k, v in message.items():
Expand All @@ -112,12 +112,11 @@ def _create_list_of_possible_encodings(message: email.message.Message) -> set:
entry = entry.strip()
if entry.startswith('charset='):
encoding = entry.replace('charset=', '').replace('"', '')
list_of_possible_encodings.add(encoding)
list_of_possible_encodings.append(encoding)

for x in ['utf-8', 'windows-1251', 'iso-8859-1', 'us-ascii', 'iso-8859-15']:
if x not in list_of_possible_encodings:
list_of_possible_encodings.add(x)

list_of_possible_encodings.append(x)
return list_of_possible_encodings

def get_attachments(self) -> List[Attachment]:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name="eml-analyzer",
version="2.0.2",
version="2.0.3",
author="Florian Wahl",
author_email="florian.wahl.developer@gmail.com",
description="A cli script to analyze an E-Mail in the eml format for viewing the header, extracting attachments, etc.",
Expand Down
2 changes: 2 additions & 0 deletions tests/library/parser/test_parsed_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def test_parser_embedded_urls_from_text_case_2(self):
found_urls = ParsedEmail._get_embedded_urls_from_text(text="""https://carleton.ca/</a></span></div>""")
self.assertEqual(1, len(found_urls))
self.assertIn('https://carleton.ca/</a></span></div>', found_urls)

def test_parser_embedded_urls_from_text_case_3(self):
""" tested in Outlook. Outlook makes the string "https://carleton.ca/"</a></span></div>" clickable """
found_urls = ParsedEmail._get_embedded_urls_from_text(text="""link: "https://carleton.ca/"</a></span></div>""")
Expand Down Expand Up @@ -220,6 +221,7 @@ def test_get_reloaded_content_from_html_case_2(self):
</html>
""")
self.assertEqual(0, len(embedded_urls))

def test_get_reloaded_content_from_html_case_3(self):
embedded_urls = ParsedEmail._get_reloaded_content_from_html(html_data="""<img class="EmojiInsert" src="data:image/gif;base64,{BASE64 emoji}" />""")
self.assertEqual(0, len(embedded_urls))
Expand Down

0 comments on commit e163290

Please sign in to comment.