|
|
|
@ -79,9 +79,9 @@ def guess_mime(cnt):
|
|
|
|
|
mime = _guess_mime(data) |
|
|
|
|
if mime is not None: |
|
|
|
|
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: |
|
|
|
|
mime = "application/x-tar" |
|
|
|
|
mime = "application/tar" |
|
|
|
|
yield MailTest("Unable to guess content-type of your submission. Assuming: %s." % mime) |
|
|
|
|
|
|
|
|
|
yield data, mime, sha, login |
|
|
|
@ -104,11 +104,17 @@ def extract(cnt, dest=None):
|
|
|
|
|
with tempfile.TemporaryDirectory() as temp: |
|
|
|
|
with subprocess.Popen(["tar", "--no-same-owner", "--no-same-permissions", |
|
|
|
|
("-xvC" + temp) if dest is not None else "-t", |
|
|
|
|
"-z" if type == "application/x-gzip" else "", |
|
|
|
|
"-J" if type == "application/x-xz" else "", |
|
|
|
|
"-j" if type in ["application/x-bzip", "application/x-bzip2"] else "", |
|
|
|
|
"-z" if type in ["application/gzip", "application/x-gzip"] else "", |
|
|
|
|
"-J" if type in ["application/xz", "application/x-xz"] 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: |
|
|
|
|
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.wait() |
|
|
|
|
err = p.stdout.read().decode('utf-8', 'replace') |
|
|
|
|