mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
[3.11] gh-99576: Fix cookiejar file that was not truncated for some classes (GH-99616) (GH-100377)
(cherry picked from commit 44892d45b0
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
1332fdabba
commit
73d2b15bd2
3 changed files with 36 additions and 2 deletions
|
@ -1890,7 +1890,10 @@ class LWPCookieJar(FileCookieJar):
|
|||
if self.filename is not None: filename = self.filename
|
||||
else: raise ValueError(MISSING_FILENAME_TEXT)
|
||||
|
||||
with os.fdopen(os.open(filename, os.O_CREAT | os.O_WRONLY, 0o600), 'w') as f:
|
||||
with os.fdopen(
|
||||
os.open(filename, os.O_CREAT | os.O_WRONLY | os.O_TRUNC, 0o600),
|
||||
'w',
|
||||
) as f:
|
||||
# There really isn't an LWP Cookies 2.0 format, but this indicates
|
||||
# that there is extra information in here (domain_dot and
|
||||
# port_spec) while still being compatible with libwww-perl, I hope.
|
||||
|
@ -2086,7 +2089,10 @@ class MozillaCookieJar(FileCookieJar):
|
|||
if self.filename is not None: filename = self.filename
|
||||
else: raise ValueError(MISSING_FILENAME_TEXT)
|
||||
|
||||
with os.fdopen(os.open(filename, os.O_CREAT | os.O_WRONLY, 0o600), 'w') as f:
|
||||
with os.fdopen(
|
||||
os.open(filename, os.O_CREAT | os.O_WRONLY | os.O_TRUNC, 0o600),
|
||||
'w',
|
||||
) as f:
|
||||
f.write(NETSCAPE_HEADER_TEXT)
|
||||
now = time.time()
|
||||
for cookie in self:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue