Dealing with application/x- and without x-
This commit is contained in:
parent
e6e622df94
commit
65fb49d080
18
archive.py
18
archive.py
@ -79,9 +79,9 @@ def guess_mime(cnt):
|
|||||||
mime = _guess_mime(data)
|
mime = _guess_mime(data)
|
||||||
if mime is not None:
|
if mime is not None:
|
||||||
yield MailTest("Guessed content-type of your submission: %s." % mime,
|
yield MailTest("Guessed content-type of your submission: %s." % mime,
|
||||||
0 if mime.find("application/x-") == 0 else 2)
|
0 if mime.find("application/") == 0 else 2)
|
||||||
else:
|
else:
|
||||||
mime = "application/x-tar"
|
mime = "application/tar"
|
||||||
yield MailTest("Unable to guess content-type of your submission. Assuming: %s." % mime)
|
yield MailTest("Unable to guess content-type of your submission. Assuming: %s." % mime)
|
||||||
|
|
||||||
yield data, mime, sha, login
|
yield data, mime, sha, login
|
||||||
@ -104,11 +104,17 @@ def extract(cnt, dest=None):
|
|||||||
with tempfile.TemporaryDirectory() as temp:
|
with tempfile.TemporaryDirectory() as temp:
|
||||||
with subprocess.Popen(["tar", "--no-same-owner", "--no-same-permissions",
|
with subprocess.Popen(["tar", "--no-same-owner", "--no-same-permissions",
|
||||||
("-xvC" + temp) if dest is not None else "-t",
|
("-xvC" + temp) if dest is not None else "-t",
|
||||||
"-z" if type == "application/x-gzip" else "",
|
"-z" if type in ["application/gzip", "application/x-gzip"] else "",
|
||||||
"-J" if type == "application/x-xz" else "",
|
"-J" if type in ["application/xz", "application/x-xz"] else "",
|
||||||
"-j" if type in ["application/x-bzip", "application/x-bzip2"] else "",
|
"-j" if type in ["application/bzip", "application/bzip2", "application/x-bzip", "application/x-bzip2"] else "",
|
||||||
"-"], env={"LANG": 'C'}, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p:
|
"-"], env={"LANG": 'C'}, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p:
|
||||||
p.stdin.write(data.encode() if isinstance(data, str) else data)
|
try:
|
||||||
|
p.stdin.write(data.encode() if isinstance(data, str) else data)
|
||||||
|
except Exception as e:
|
||||||
|
print(type)
|
||||||
|
print(p.stdout.read().decode('utf-8', 'replace'))
|
||||||
|
print(p.stderr.read().decode('utf-8', 'replace'))
|
||||||
|
raise e
|
||||||
p.stdin.close()
|
p.stdin.close()
|
||||||
p.wait()
|
p.wait()
|
||||||
err = p.stdout.read().decode('utf-8', 'replace')
|
err = p.stdout.read().decode('utf-8', 'replace')
|
||||||
|
Reference in New Issue
Block a user