From 306f4d1660829fc4c56d8a56f3a28044dbd99d68 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Tue, 12 May 2026 15:47:44 +0200 Subject: [PATCH] url-cookie: use C locale when formatting expiry times The expiry time needs to be reconizable by parse-time-string, which is only guaranteed with the C locale. * lisp/url/url-cookie.el (url-cookie-parse-file-netscape): Use C locale for formatted expiry time. (url-cookie-handle-set-cookie): Likewise. --- lisp/url/url-cookie.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lisp/url/url-cookie.el b/lisp/url/url-cookie.el index 153d39213b4..2cc67a030ce 100644 --- a/lisp/url/url-cookie.el +++ b/lisp/url/url-cookie.el @@ -103,12 +103,13 @@ i.e. 1970-1-1) are loaded as expiring one year from now instead." ;; reuse a browser session, so to prevent the ;; cookie from being detected as expired straight ;; away, make it expire a year from now - (expires (format-time-string - "%d %b %Y %T [GMT]" - (let ((s (string-to-number (nth 4 fields)))) - (if (and (zerop s) long-session) - (time-add nil (* 365 24 60 60)) - s)))) + (expires (let ((system-time-locale "C")) + (format-time-string + "%d %b %Y %T [GMT]" + (let ((s (string-to-number (nth 4 fields)))) + (if (and (zerop s) long-session) + (time-add nil (* 365 24 60 60)) + s))))) (key (nth 5 fields)) (val (nth 6 fields))) (incf n) @@ -300,9 +301,10 @@ i.e. 1970-1-1) are loaded as expiring one year from now instead." (expires nil)) (if (and max-age (string-match "\\`-?[0-9]+\\'" max-age)) (setq expires (ignore-errors - (format-time-string "%a %b %d %H:%M:%S %Y GMT" - (time-add nil (read max-age)) - t))) + (let ((system-time-locale "C")) + (format-time-string "%a %b %d %H:%M:%S %Y GMT" + (time-add nil (read max-age)) + t))) (setq expires (cdr-safe (assoc-string "expires" args t)))) (while (consp trusted) (if (string-match (car trusted) current-url)