Skip to content

Commit 013744b

Browse files
committed
📚 Document Envelope: nil/empty/default semantics
1 parent d0d9339 commit 013744b

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

lib/net/imap/response_data.rb

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,31 +672,64 @@ class Envelope < Struct.new(:date, :subject, :from, :sender, :reply_to,
672672
# call-seq: date -> string
673673
#
674674
# Returns a string that represents the +Date+ header.
675+
#
676+
# [Note]
677+
# For a well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
678+
# message, the #date field must not be +nil+. However it can be +nil+
679+
# for a malformed or draft message.
675680

676681
##
677682
# method: subject
678683
# call-seq: subject -> string or nil
679684
#
680685
# Returns a string that represents the +Subject+ header, if it is present.
686+
#
687+
# [Note]
688+
# Servers should return +nil+ when the header is absent and an empty
689+
# string when it is present but empty. Some servers may return a +nil+
690+
# envelope member in the "present but empty" case. Clients should treat
691+
# +nil+ and empty string as identical.
681692

682693
##
683694
# method: from
684695
# call-seq: from -> array of Net::IMAP::Address or nil
685696
#
686697
# Returns an array of Address that represents the +From+ header.
698+
#
699+
# If the +From+ header is absent, or is present but empty, the server
700+
# returns +nil+ for this envelope field.
701+
#
702+
# [Note]
703+
# For a well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
704+
# message, the #from field must not be +nil+. However it can be +nil+
705+
# for a malformed or draft message.
687706

688707
##
689708
# method: sender
690709
# call-seq: sender -> array of Net::IMAP::Address or nil
691710
#
692711
# Returns an array of Address that represents the +Sender+ header.
712+
#
713+
# [Note]
714+
# If the <tt>Sender</tt> header is absent, or is present but empty, the
715+
# server sets this field to be the same value as #from. Therefore, in a
716+
# well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]] message,
717+
# the #sender envelope field must not be +nil+. However it can be
718+
# +nil+ for a malformed or draft message.
693719

694720
##
695721
# method: reply_to
696722
# call-seq: reply_to -> array of Net::IMAP::Address or nil
697723
#
698724
# Returns an array of Address that represents the <tt>Reply-To</tt>
699725
# header.
726+
#
727+
# [Note]
728+
# If the <tt>Reply-To</tt> header is absent, or is present but empty,
729+
# the server sets this field to be the same value as #from. Therefore,
730+
# in a well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
731+
# message, the #reply_to envelope field must not be +nil+. However it
732+
# can be +nil+ for a malformed or draft message.
700733

701734
##
702735
# method: to
@@ -721,12 +754,32 @@ class Envelope < Struct.new(:date, :subject, :from, :sender, :reply_to,
721754
# call-seq: in_reply_to -> string
722755
#
723756
# Returns a string that represents the <tt>In-Reply-To</tt> header.
757+
#
758+
# [Note]
759+
# For a well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
760+
# message, the #in_reply_to field, if present, must not be empty. But
761+
# it can still return an empty string for malformed messages.
762+
#
763+
# Servers should return +nil+ when the header is absent and an empty
764+
# string when it is present but empty. Some servers may return a +nil+
765+
# envelope member in the "present but empty" case. Clients should treat
766+
# +nil+ and empty string as identical.
724767

725768
##
726769
# method: message_id
727770
# call-seq: message_id -> string
728771
#
729772
# Returns a string that represents the <tt>Message-ID</tt>.
773+
#
774+
# [Note]
775+
# For a well-formed [RFC5322[https://tools.ietf.org/html/rfc5322]]
776+
# message, the #message_id field, if present, must not be empty. But it
777+
# can still return an empty string for malformed messages.
778+
#
779+
# Servers should return +nil+ when the header is absent and an empty
780+
# string when it is present but empty. Some servers may return a +nil+
781+
# envelope member in the "present but empty" case. Clients should treat
782+
# +nil+ and empty string as identical.
730783
end
731784

732785
#

0 commit comments

Comments
 (0)