mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-12-24 07:37:04 +00:00
process images returned from mailgraph
This commit is contained in:
parent
5b5087c9dd
commit
dce4058705
@ -522,23 +522,29 @@ def privacy_status_set():
|
|||||||
|
|
||||||
# Mailgraph
|
# Mailgraph
|
||||||
|
|
||||||
@app.route('/mailgraph/image.cgi')
|
@app.route('/mailgraph/image.cgi', methods=['GET'])
|
||||||
@authorized_personnel_only
|
@authorized_personnel_only
|
||||||
def mailgraph():
|
def mailgraph():
|
||||||
if request.query_string:
|
if request.query_string:
|
||||||
print("QUERY_STRING=%s" % request.query_string)
|
app.logger.error("QUERY_STRING=%s" % request.query_string)
|
||||||
|
|
||||||
code, bin_out = utils.shell(
|
code, bin_out = utils.shell(
|
||||||
"check_output",
|
"check_output",
|
||||||
["/usr/share/mailgraph/mailgraph.cgi"],
|
["/usr/share/mailgraph/mailgraph.cgi"],
|
||||||
env={"QUERY_STRING": request.query_string},
|
env={"QUERY_STRING": request.query_string},
|
||||||
return_bytes=True
|
return_bytes=True,
|
||||||
|
trap=True
|
||||||
)
|
)
|
||||||
|
|
||||||
if code != 0:
|
if code != 0:
|
||||||
return ('Error generating mailgraph image: %s' % request.query_string, 500)
|
return ('Error generating mailgraph image: %s' % request.query_string, 500)
|
||||||
|
|
||||||
return make_response(bin_out)
|
headers, image_bytes = bin_out.split(b'\n\n', 1)
|
||||||
|
response = make_response(image_bytes)
|
||||||
|
for line in headers.splitlines():
|
||||||
|
name, value = line.decode("utf8").split(':', 1)
|
||||||
|
response.headers[name] = value
|
||||||
|
return response
|
||||||
|
|
||||||
return ('Mailgraph: no image requested', 500)
|
return ('Mailgraph: no image requested', 500)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user