aboutsummaryrefslogtreecommitdiffstats
path: root/interfaces/email
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-07-18 10:35:17 -0400
committerW. Trevor King <wking@drexel.edu>2009-07-18 10:35:17 -0400
commit611da693ba37d39d0f9682973a2f5c0a991c74e7 (patch)
tree5ffe0eced825e0e0f63c976bd47983dd86bed92d /interfaces/email
parentab27f54efd8c7f8fd095c64a136a2e88852e1e88 (diff)
downloadbugseverywhere-611da693ba37d39d0f9682973a2f5c0a991c74e7.tar.gz
For be-handle-mail, pass comment body in via a temporary stdin.
This avoids decode-recode issues inside libbe.cmdutil.execute(), as well as problems due to large comment bodies.
Diffstat (limited to 'interfaces/email')
-rwxr-xr-xinterfaces/email/interactive/be-handle-mail12
1 files changed, 9 insertions, 3 deletions
diff --git a/interfaces/email/interactive/be-handle-mail b/interfaces/email/interactive/be-handle-mail
index 013ea4e..c3769be 100755
--- a/interfaces/email/interactive/be-handle-mail
+++ b/interfaces/email/interactive/be-handle-mail
@@ -130,6 +130,7 @@ def run_message(msg_text):
command_args = args[2:]
else:
command_args = []
+ stdin = None
if command in ["new", "comment"]:
body,mime_type = get_body_type(msg)
if command == "new":
@@ -143,13 +144,17 @@ def run_message(msg_text):
command_args = ["--content-type", mime_type] + command_args
if "--alt-id" not in args:
command_args = ["--alt-id", msg["message-id"]] + command_args
- command_args.append(body)
+ command_args.append("-")
+ stdin = body
info["command-args"] = command_args
- # catch stdout and stderr
+ # set stdin and catch stdout and stderr
+ new_stdin = StringIO.StringIO(stdin)
new_stdout = codecs.getwriter(ENCODING)(StringIO.StringIO())
new_stderr = codecs.getwriter(ENCODING)(StringIO.StringIO())
+ orig_stdin = sys.stdin
orig_stdout = sys.stdout
orig_stderr = sys.stderr
+ sys.stdin = new_stdin
sys.stdout = new_stdout
sys.stderr = new_stderr
# run the command
@@ -166,9 +171,10 @@ def run_message(msg_text):
err = InvalidCommand(msg, info, e)
except libbe.cmdutil.UserError, e:
err = InvalidCommand(msg, info, e)
- # restore stdout and stderr
+ # restore stdin, stdout, and stderr
sys.stdout.flush()
sys.stderr.flush()
+ sys.stdin = orig_stdin
sys.stdout = orig_stdout
sys.stderr = orig_stderr
out_text = codecs.decode(new_stdout.getvalue(), ENCODING)