From 4145a35700f578d1d9307242619fd5e32c96c40f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Thu, 26 Nov 1998 10:26:53 +0100 Subject: [PATCH] Pass the request tag in the action mapping for the BAD response. Rev: lib/modules/Protocols.pmod/IMAP.pmod/imap_server.pike:1.8 Rev: lib/modules/Protocols.pmod/IMAP.pmod/requests.pmod:1.15 --- .../Protocols.pmod/IMAP.pmod/imap_server.pike | 5 ++-- .../Protocols.pmod/IMAP.pmod/requests.pmod | 27 ++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/modules/Protocols.pmod/IMAP.pmod/imap_server.pike b/lib/modules/Protocols.pmod/IMAP.pmod/imap_server.pike index fe4256c011..e09138216b 100644 --- a/lib/modules/Protocols.pmod/IMAP.pmod/imap_server.pike +++ b/lib/modules/Protocols.pmod/IMAP.pmod/imap_server.pike @@ -61,7 +61,7 @@ class connection mapping session = ([]); /* State information about this ession; primarily * uid and mailboxid. */ - object current_request; + // object current_request; class get_line { @@ -106,7 +106,8 @@ class connection /* Close connection */ io->close_imap(); case "bad": - io->send_bad_response(action->msg || "Invalid request"); + io->send_bad_response(action->tag, + action->msg || "Invalid request"); /* Fall through */ case "finished": /* Finished processing this request. Remain in the same state. */ diff --git a/lib/modules/Protocols.pmod/IMAP.pmod/requests.pmod b/lib/modules/Protocols.pmod/IMAP.pmod/requests.pmod index 191d3b30eb..1f10378133 100644 --- a/lib/modules/Protocols.pmod/IMAP.pmod/requests.pmod +++ b/lib/modules/Protocols.pmod/IMAP.pmod/requests.pmod @@ -3,7 +3,9 @@ */ import .types; - + +// FIXME: Pass the current request's tag when returning a "bad" action. + class request { string tag; @@ -13,7 +15,6 @@ class request function send; - void create(string t, object line) { tag = t; @@ -25,6 +26,11 @@ class request constant arg_info = ({ }); + mapping bad(string msg) + { + return ([ "action" : bat, "tag" : tag, "msg" : msg]); + } + mapping easy_process(mixed ... args); array args; @@ -52,8 +58,7 @@ class request mapping append_arg(mixed o) { if (!o) - return ([ "action" : "bad", - "msg" : "Invalid or missing argument" ]); + return bad("Invalid or missing argument"); args[argc++] = o; return collect_args(); @@ -281,8 +286,7 @@ class fetch mixed f = process_fetch_attr(request); if (!f) { - send(tag, "BAD"); - return ([ "action" : "finished" ]); + return bad("Invalid fetch"); } fetch_attrs = ({ f }); } @@ -293,8 +297,7 @@ class fetch { if (!(fetch_attrs[i] = process_fetch_attr(request->list[i]))) { - send(tag, "BAD"); - return ([ "action" : "finished" ]); + return bad("Invalid fetch"); } } break; @@ -314,7 +317,7 @@ class fetch { if (stringp(e)) { - return ([ "action" : "bad", "msg" : e ]); + return bad(e); } else throw(e); } @@ -419,13 +422,13 @@ class search string charset = "us-ascii"; if (!sizeof(args)) - return ([ "action" : "bad", "msg" : "No arguments to SEARCH" ]); + return bad("No arguments to SEARCH"); if (lower(args[0]->atom) == "charset") { if ( (sizeof(args) < 2) || !(charset = astring(args[1])) ) - return ([ "action" : "bad", "msg" : "Bad charset to SEARCH" ]); + return bad("Bad charset to SEARCH"); args = args[2..]; } @@ -433,7 +436,7 @@ class search mapping criteria = parse_criteria(args)->parse_toplevel(); if (!criteria) - return ([ "action" : "bad", "msg" : "Invalid search criteria" ]); + return bad("Invalid search criteria"); array matches = server->search(session, charset, criteria); -- GitLab