diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 7ea8dad5..647974bb 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -3661,10 +3661,8 @@ def send_command_with_continuations(cmd, *args) end def send_command(cmd, *args, &block) + args.each do validate_data _1 end synchronize do - args.each do |i| - validate_data(i) - end tag = generate_tag command = Command[tag:, name: cmd] put_string(tag + " " + cmd) @@ -3681,10 +3679,10 @@ def send_command(cmd, *args, &block) ensure remove_response_handler(block) if block end + rescue InvalidResponseError + disconnect + raise end - rescue InvalidResponseError - disconnect - raise end # NOTE: This must be synchronized with sending the command's final CRLF and