@@ -59,6 +59,52 @@ def test_basic(self):
5959 for k , v in sorted (case ['dict' ].items ()):
6060 self .assertEqual (C [k ].value , v )
6161
62+ def test_obsolete_rfc850_date_format (self ):
63+ # Test cases with different days and dates in obsolete RFC 850 format
64+ test_cases = [
65+ # from RFC 850, change EST to GMT
66+ # https://datatracker.ietf.org/doc/html/rfc850#section-2
67+ {
68+ 'data' : 'key=value; expires=Saturday, 01-Jan-83 00:00:00 GMT' ,
69+ 'output' : 'Saturday, 01-Jan-83 00:00:00 GMT'
70+ },
71+ {
72+ 'data' : 'key=value; expires=Friday, 19-Nov-82 16:59:30 GMT' ,
73+ 'output' : 'Friday, 19-Nov-82 16:59:30 GMT'
74+ },
75+ # from RFC 9110
76+ # https://www.rfc-editor.org/rfc/rfc9110.html#section-5.6.7-6
77+ {
78+ 'data' : 'key=value; expires=Sunday, 06-Nov-94 08:49:37 GMT' ,
79+ 'output' : 'Sunday, 06-Nov-94 08:49:37 GMT'
80+ },
81+ # other test cases
82+ {
83+ 'data' : 'key=value; expires=Wednesday, 09-Nov-94 08:49:37 GMT' ,
84+ 'output' : 'Wednesday, 09-Nov-94 08:49:37 GMT'
85+ },
86+ {
87+ 'data' : 'key=value; expires=Friday, 11-Nov-94 08:49:37 GMT' ,
88+ 'output' : 'Friday, 11-Nov-94 08:49:37 GMT'
89+ },
90+ {
91+ 'data' : 'key=value; expires=Monday, 14-Nov-94 08:49:37 GMT' ,
92+ 'output' : 'Monday, 14-Nov-94 08:49:37 GMT'
93+ },
94+ ]
95+
96+ for case in test_cases :
97+ with self .subTest (data = case ['data' ]):
98+ C = cookies .SimpleCookie ()
99+ C .load (case ['data' ])
100+
101+ # Extract the cookie name from the data string
102+ cookie_name = case ['data' ].split ('=' )[0 ]
103+
104+ # Check if the cookie is loaded correctly
105+ self .assertIn (cookie_name , C )
106+ self .assertEqual (C [cookie_name ].get ('expires' ), case ['output' ])
107+
62108 def test_unquote (self ):
63109 cases = [
64110 (r'a="b=\""' , 'b="' ),
0 commit comments