[3.14] gh-139434: Update selected RFC 2822 references to RFC 5322 (GH-139435) (#141025)

Update selected RFC 2822 references to RFC 5322

RFC 2822 was obsoleted by RFC 5322 in 2008. This updates references
to use the current standard in documentation, docstrings, and comments.

It preserves RFC 2822 references in legacy API components to maintain their
historical context.

RFC 822 → RFC 2822 → RFC 5322 progression is explained where relevant.

In some places specific sections of RFC are referenced where it seems helpful.

Scout rule was applied in some places and RFC mentions format was
normalized in doc strings and comments.
(cherry picked from commit ce1bb85d28)
This commit is contained in:
Filip Łajszczak 2025-11-04 22:23:16 +01:00 committed by GitHub
parent f0eb7d4c9a
commit dc76de26e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 49 additions and 45 deletions

View file

@ -2352,7 +2352,7 @@ def test_no_separating_blank_line(self):
To: bperson@dom.ain
Subject: here's something interesting
counter to RFC 2822, there's no separating newline here
counter to RFC 5322, there's no separating newline here
""")
# test_defect_handling
@ -2508,49 +2508,49 @@ def test_rfc2047_Q_invalid_digits(self):
[(b'andr\xe9=zz', 'iso-8859-1')])
def test_rfc2047_rfc2047_1(self):
# 1st testcase at end of rfc2047
# 1st testcase at end of RFC 2047
s = '(=?ISO-8859-1?Q?a?=)'
self.assertEqual(decode_header(s),
[(b'(', None), (b'a', 'iso-8859-1'), (b')', None)])
def test_rfc2047_rfc2047_2(self):
# 2nd testcase at end of rfc2047
# 2nd testcase at end of RFC 2047
s = '(=?ISO-8859-1?Q?a?= b)'
self.assertEqual(decode_header(s),
[(b'(', None), (b'a', 'iso-8859-1'), (b' b)', None)])
def test_rfc2047_rfc2047_3(self):
# 3rd testcase at end of rfc2047
# 3rd testcase at end of RFC 2047
s = '(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)'
self.assertEqual(decode_header(s),
[(b'(', None), (b'ab', 'iso-8859-1'), (b')', None)])
def test_rfc2047_rfc2047_4(self):
# 4th testcase at end of rfc2047
# 4th testcase at end of RFC 2047
s = '(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)'
self.assertEqual(decode_header(s),
[(b'(', None), (b'ab', 'iso-8859-1'), (b')', None)])
def test_rfc2047_rfc2047_5a(self):
# 5th testcase at end of rfc2047 newline is \r\n
# 5th testcase at end of RFC 2047 newline is \r\n
s = '(=?ISO-8859-1?Q?a?=\r\n =?ISO-8859-1?Q?b?=)'
self.assertEqual(decode_header(s),
[(b'(', None), (b'ab', 'iso-8859-1'), (b')', None)])
def test_rfc2047_rfc2047_5b(self):
# 5th testcase at end of rfc2047 newline is \n
# 5th testcase at end of RFC 2047 newline is \n
s = '(=?ISO-8859-1?Q?a?=\n =?ISO-8859-1?Q?b?=)'
self.assertEqual(decode_header(s),
[(b'(', None), (b'ab', 'iso-8859-1'), (b')', None)])
def test_rfc2047_rfc2047_6(self):
# 6th testcase at end of rfc2047
# 6th testcase at end of RFC 2047
s = '(=?ISO-8859-1?Q?a_b?=)'
self.assertEqual(decode_header(s),
[(b'(', None), (b'a b', 'iso-8859-1'), (b')', None)])
def test_rfc2047_rfc2047_7(self):
# 7th testcase at end of rfc2047
# 7th testcase at end of RFC 2047
s = '(=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=)'
self.assertEqual(decode_header(s),
[(b'(', None), (b'a', 'iso-8859-1'), (b' b', 'iso-8859-2'),
@ -3252,8 +3252,8 @@ def test_parsedate_y2k(self):
"""Test for parsing a date with a two-digit year.
Parsing a date with a two-digit year should return the correct
four-digit year. RFC822 allows two-digit years, but RFC2822 (which
obsoletes RFC822) requires four-digit years.
four-digit year. RFC 822 allows two-digit years, but RFC 5322 (which
obsoletes RFC 2822, which obsoletes RFC 822) requires four-digit years.
"""
self.assertEqual(utils.parsedate_tz('25 Feb 03 13:47:26 -0800'),
@ -3304,7 +3304,7 @@ def test_escape_backslashes(self):
self.assertEqual(utils.parseaddr(utils.formataddr((a, b))), (a, b))
def test_quotes_unicode_names(self):
# issue 1690608. email.utils.formataddr() should be rfc2047 aware.
# issue 1690608. email.utils.formataddr() should be RFC 2047 aware.
name = "H\u00e4ns W\u00fcrst"
addr = 'person@dom.ain'
utf8_base64 = "=?utf-8?b?SMOkbnMgV8O8cnN0?= <person@dom.ain>"
@ -3314,7 +3314,7 @@ def test_quotes_unicode_names(self):
latin1_quopri)
def test_accepts_any_charset_like_object(self):
# issue 1690608. email.utils.formataddr() should be rfc2047 aware.
# issue 1690608. email.utils.formataddr() should be RFC 2047 aware.
name = "H\u00e4ns W\u00fcrst"
addr = 'person@dom.ain'
utf8_base64 = "=?utf-8?b?SMOkbnMgV8O8cnN0?= <person@dom.ain>"
@ -3329,7 +3329,7 @@ def header_encode(self, string):
utf8_base64)
def test_invalid_charset_like_object_raises_error(self):
# issue 1690608. email.utils.formataddr() should be rfc2047 aware.
# issue 1690608. email.utils.formataddr() should be RFC 2047 aware.
name = "H\u00e4ns W\u00fcrst"
addr = 'person@dom.ain'
# An object without a header_encode method:
@ -3338,7 +3338,7 @@ def test_invalid_charset_like_object_raises_error(self):
bad_charset)
def test_unicode_address_raises_error(self):
# issue 1690608. email.utils.formataddr() should be rfc2047 aware.
# issue 1690608. email.utils.formataddr() should be RFC 2047 aware.
addr = 'pers\u00f6n@dom.in'
self.assertRaises(UnicodeError, utils.formataddr, (None, addr))
self.assertRaises(UnicodeError, utils.formataddr, ("Name", addr))
@ -3359,7 +3359,7 @@ def test_parseaddr_preserves_quoted_pairs_in_addresses(self):
# string containing a quoted backslash, followed by 'example' and two
# backslashes, followed by another quoted string containing a space and
# the word 'example'. parseaddr copies those two backslashes
# literally. Per rfc5322 this is not technically correct since a \ may
# literally. Per RFC 5322 this is not technically correct since a \ may
# not appear in an address outside of a quoted string. It is probably
# a sensible Postel interpretation, though.
eq = self.assertEqual
@ -3371,12 +3371,12 @@ def test_parseaddr_preserves_quoted_pairs_in_addresses(self):
('', '"\\\\"example\\\\" example"@example.com'))
def test_parseaddr_preserves_spaces_in_local_part(self):
# issue 9286. A normal RFC5322 local part should not contain any
# issue 9286. A normal RFC 5322 local part should not contain any
# folding white space, but legacy local parts can (they are a sequence
# of atoms, not dotatoms). On the other hand we strip whitespace from
# before the @ and around dots, on the assumption that the whitespace
# around the punctuation is a mistake in what would otherwise be
# an RFC5322 local part. Leading whitespace is, usual, stripped as well.
# an RFC 5322 local part. Leading whitespace is, usual, stripped as well.
self.assertEqual(('', "merwok wok@xample.com"),
utils.parseaddr("merwok wok@xample.com"))
self.assertEqual(('', "merwok wok@xample.com"),