Skip to content

Commit 89abdc6

Browse files
authored
Merge pull request #774 from gallypette/main
chg: [email_import] avoid treating non http https urls as url
2 parents f1def8a + fbf6fe6 commit 89abdc6

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

misp_modules/modules/import_mod/email_import.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ def dict_handler(request: dict):
170170
for url in urls:
171171
if not url:
172172
continue
173-
url_object = URLObject(url, standalone=False)
173+
try:
174+
url_object = URLObject(url, standalone=False)
175+
except ValueError:
176+
continue
174177
file_objects.append(url_object)
175178
email_object.add_reference(url_object.uuid, "includes", "URL in email body")
176179

@@ -344,9 +347,15 @@ def __init__(self, urls=None):
344347

345348
def handle_starttag(self, tag, attrs):
346349
if tag == "a":
347-
self.urls.append(dict(attrs).get("href"))
350+
value = self.urls.append(dict(attrs).get("href"))
348351
if tag == "img":
349-
self.urls.append(dict(attrs).get("src"))
352+
value = self.urls.append(dict(attrs).get("src"))
353+
else:
354+
return
355+
356+
# avoid references like internal cid:
357+
if value and value.lower().startswith(("http://", "https://")):
358+
self.urls.append(value)
350359

351360

352361
def introspection():

0 commit comments

Comments
 (0)