@@ -11,6 +11,10 @@ class SameSite(Enum):
11
11
NONE_MODE = "None"
12
12
13
13
14
+ def _getdate (timestamp : datetime ) -> str :
15
+ return timestamp .strftime ("%a, %d %b %Y %H:%M:%S GMT" )
16
+
17
+
14
18
class Cookie :
15
19
def __init__ (
16
20
self ,
@@ -38,21 +42,16 @@ def __init__(
38
42
39
43
def __str__ (self ) -> str :
40
44
payload = StringIO ()
41
- payload .write (f"{ self .name } =" )
42
-
43
- # Maintenance(rf): the value needs to be sanitized
44
- payload .write (self .value )
45
+ payload .write (f"{ self .name } ={ self .value } " )
45
46
46
47
if self .path and len (self .path ) > 0 :
47
- # Maintenance(rf): the value of path needs to be sanitized
48
48
payload .write (f"; Path={ self .path } " )
49
49
50
50
if self .domain and len (self .domain ) > 0 :
51
51
payload .write (f"; Domain={ self .domain } " )
52
52
53
53
if self .expires :
54
- # Maintenance(rf) this format is wrong
55
- payload .write (f"; Expires={ self .expires .strftime ('YYYY-MM-dd' )} " )
54
+ payload .write (f"; Expires={ _getdate (self .expires )} " )
56
55
57
56
if self .max_age :
58
57
if self .max_age > 0 :
@@ -71,7 +70,6 @@ def __str__(self) -> str:
71
70
72
71
if self .custom_attributes :
73
72
for attr in self .custom_attributes :
74
- # Maintenance(rf): the value needs to be sanitized
75
73
payload .write (f"; { attr } " )
76
74
77
75
return payload .getvalue ()
0 commit comments