Skip to content

Commit 51a384b

Browse files
author
Daniel Herzog
committed
Fix for DFL-3361: Cookies expires date is not preserved when editing
1 parent 26f2e6f commit 51a384b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/cookie-manager/cookie_manager_views.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ cls.CookieManager.CookieManagerViewBase = function()
421421

422422
var name = edit_tr.querySelector("[name='name']").value.trim();
423423
var value = edit_tr.querySelector("[name='value']").value;
424-
var expires = new Date(edit_tr.querySelector("[name='expires']").value || 0).getTime();
424+
var expires = edit_tr.querySelector("[name='expires']").value;
425425
var path = edit_tr.querySelector("[name='path']").value.trim();
426426
var is_secure = +(is_secure_input && is_secure_input.checked);
427427
var is_http_only = +(is_http_only_input && is_http_only_input.checked);
@@ -430,6 +430,15 @@ cls.CookieManager.CookieManagerViewBase = function()
430430
// "domain" is val of [input] (with add_cookie service present), or runtimes .hostname
431431
var domain = domain_input && domain_input.value.trim() || runtime && this.data._rts[runtime].hostname;
432432

433+
// Fix expires value, work around CORE-47780: .value property of <input type=datetime-local>
434+
// element has two digits representing milliseconds, instead of three.
435+
if (expires.split(".").length > 1)
436+
{
437+
if (expires.split(".")[1].length < 3)
438+
expires += "0";
439+
}
440+
expires = new Date(expires || 0).getTime();
441+
433442
var object_id = edit_tr.getAttribute("data-object-id");
434443
var old_cookie;
435444
if (object_id)

0 commit comments

Comments
 (0)