[4chan] detect files containing only null bytes (#7883)
This commit is contained in:
@@ -44,11 +44,23 @@ class _4chanThreadExtractor(Extractor):
|
||||
post.update(data)
|
||||
post["extension"] = post["ext"][1:]
|
||||
post["filename"] = text.unescape(post["filename"])
|
||||
post["_http_signature"] = _detect_null_byte
|
||||
url = (f"https://i.4cdn.org"
|
||||
f"/{post['board']}/{post['tim']}{post['ext']}")
|
||||
yield Message.Url, url, post
|
||||
|
||||
|
||||
def _detect_null_byte(signature):
|
||||
"""Return False if all file signature bytes are null"""
|
||||
if signature:
|
||||
if signature[0]:
|
||||
return True
|
||||
for byte in signature:
|
||||
if byte:
|
||||
return True
|
||||
return "File data consists of null bytes"
|
||||
|
||||
|
||||
class _4chanBoardExtractor(Extractor):
|
||||
"""Extractor for 4chan boards"""
|
||||
category = "4chan"
|
||||
|
||||
Reference in New Issue
Block a user