Exception: Net::IMAP::InvalidTaggedResponseError
- Inherits:
-
InvalidResponseError
- Object
- StandardError
- Error
- InvalidResponseError
- Net::IMAP::InvalidTaggedResponseError
- Defined in:
- lib/net/imap/errors.rb
Overview
Error raised when the server sends a tagged #response that is invalid for the #command #state.
This could be caused by a bug in the server or in Net::IMAP. Or it might indicate a malicious server, a man-in-the-middle attack, or client-side command injection, so the client should disconnect automatically and abruptly (without logout).
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Metadata about the matching IMAP command.
-
#response ⇒ Object
readonly
The TaggedResponse which triggered this error.
-
#state ⇒ Object
readonly
A symbol representing the state of the matching tagged command.
Instance Method Summary collapse
- #detailed_message ⇒ Object
-
#initialize(state, response:, command: nil) ⇒ InvalidTaggedResponseError
constructor
A new instance of InvalidTaggedResponseError.
Constructor Details
#initialize(state, response:, command: nil) ⇒ InvalidTaggedResponseError
Returns a new instance of InvalidTaggedResponseError.
333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/net/imap/errors.rb', line 333 def initialize(state, response:, command: nil) response => TaggedResponse[tag:, name: status] case [state, status, command] in :unknown, _, nil in :incomplete, "OK", {tag: ^tag, name:} in :unstarted | :completed, _, {tag: ^tag, name:} end @state, @command, @response = state, command, response cmd_desc = name ? "#{state} #{name}" : state super "Received tagged #{status} to #{cmd_desc} command (tag=#{tag})" rescue NoMatchingPatternError => err raise ArgumentError, err. end |
Instance Attribute Details
#command ⇒ Object (readonly)
Metadata about the matching IMAP command.
Returns nil when #state is :unknown.
NOTE: The non-nil return type is an unstable API, for debug only. It may be changed by any release, without warning or deprecation.
328 329 330 |
# File 'lib/net/imap/errors.rb', line 328 def command @command end |
#response ⇒ Object (readonly)
The TaggedResponse which triggered this error
331 332 333 |
# File 'lib/net/imap/errors.rb', line 331 def response @response end |
#state ⇒ Object (readonly)
A symbol representing the state of the matching tagged command.
:unknown::
#response does not match any known command (#command will be +nil+).
:unstarted::
Any tagged #response is invalid before #command starts sending.
:incomplete::
A tagged +OK+ #response is invalid before #command is fully sent.
:completed::
Multiple tagged responses were received for the same command.
NOTE: Command state is neither anticipated nor remembered indefinitely.
:unknown is used before the matching command is called and after the
it is forgotten.
NOTE: This version of Net::IMAP does not detect or raise an exception for all of these states.
320 321 322 |
# File 'lib/net/imap/errors.rb', line 320 def state @state end |
Instance Method Details
#detailed_message ⇒ Object
347 348 349 350 351 352 353 |
# File 'lib/net/imap/errors.rb', line 347 def (**) "#{}.\n" \ "Disconnecting: This could indicate a malicious server, a " \ "man-in-the-middle attack, a client-side command injection, or " \ "a bug in net-imap.\n" \ "response.data=#{response.data.inspect}" end |