Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#2881 closed defect (fixed)

getCookie retrieves wrong value when name is a substring of multiple cookies

Reported by: guest Owned by: Adam Peller
Priority: high Milestone: 1.1
Component: General Version: 0.4.2
Keywords: Cc: pat@…
Blocked By: Blocking:

Description

If you set two cookies "mycook" and "XXXmycook", then (depending on the order the cookies are set) getCookie('mycook') will return the value for "XXXmycook".

getCookie uses the following code which can match "mycook" and "XXXmycook": var idx = document.cookie.lastIndexOf(name+'=');

Attachments (2)

test-cookie.html (679 bytes) - added by guest 12 years ago.
Test case for getCookie bug
test-cookie-replacement.html (999 bytes) - added by guest 12 years ago.
Possible fix for getCookie using regexp

Download all attachments as: .zip

Change History (8)

Changed 12 years ago by guest

Attachment: test-cookie.html added

Test case for getCookie bug

Changed 12 years ago by guest

Possible fix for getCookie using regexp

comment:1 Changed 12 years ago by guest

Can someone add a CC: pat@…

I submitted the ticket but it didn't list me as submitter and I'd like to get updates when this is fixed.

comment:2 Changed 12 years ago by James Burke

Cc: pat@… added

comment:3 Changed 11 years ago by Adam Peller

Milestone: 1.1
Owner: changed from anonymous to Ben Lowery

looks like this code is still in 1.0+

comment:4 Changed 11 years ago by Adam Peller

Owner: changed from Ben Lowery to Adam Peller
Status: newassigned

comment:5 Changed 11 years ago by Adam Peller

Resolution: fixed
Status: assignedclosed

(In [12333]) Use regexp to find cookie contents. (thanks, Pat) Fixes #2881. Correct docs on deleting cookies. Fixes #5782 !strict

comment:6 Changed 11 years ago by Adam Peller

(In [12334]) Missed reference in reduction. Refs #2881. !strict

Note: See TracTickets for help on using tickets.