Fix bug causing broken login state w/ malformed cookie #229

Open
jmann345 wants to merge 1 commit from jmann345/fix/recover-cookie-from-devtools-paste into master
jmann345 commented 2026-07-04 18:37:40 -05:00 (Migrated from github.com)

Bug: If a cookie was pasted with surrounding text, it would be accepted as valid if it contained csrftoken= and LEETCODE_SESSION= but break when pasted in, causing leetcode.nvim to be in a broken state where I had to manually edit the cookie file in order to log in

Fix: Strip token to just the line containing csrftoken and LEETCODE_SESSION and a Cookie built from just that line.

Note: This fix may not apply for cookies malformed in other ways, but it fixed the case where I accidentally pasted surrounding text from the cookie in my web browser. A more robust solution for gracefully handling all types of malformed cookie text and recovering when possible exists.

Validation: Logged out, pasted in the same malformed cookie text i pasted in earlier, and had a successful login. Also verified that correctly-formed cookie text still works.

**Bug:** If a cookie was pasted with surrounding text, it would be accepted as valid if it contained `csrftoken=` and `LEETCODE_SESSION=` but break when pasted in, causing leetcode.nvim to be in a broken state where I had to manually edit the cookie file in order to log in **Fix:** Strip token to just the line containing `csrftoken` and `LEETCODE_SESSION` and a `Cookie` built from just that line. Note: This fix may not apply for cookies malformed in other ways, but it fixed the case where I accidentally pasted surrounding text from the cookie in my web browser. A more robust solution for gracefully handling all types of malformed cookie text and recovering when possible exists. **Validation:** Logged out, pasted in the same malformed cookie text i pasted in earlier, and had a successful login. Also verified that correctly-formed cookie text still works.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin jmann345/fix/recover-cookie-from-devtools-paste:jmann345/fix/recover-cookie-from-devtools-paste
git switch jmann345/fix/recover-cookie-from-devtools-paste

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch master
git merge --no-ff jmann345/fix/recover-cookie-from-devtools-paste
git switch jmann345/fix/recover-cookie-from-devtools-paste
git rebase master
git switch master
git merge --ff-only jmann345/fix/recover-cookie-from-devtools-paste
git switch jmann345/fix/recover-cookie-from-devtools-paste
git rebase master
git switch master
git merge --no-ff jmann345/fix/recover-cookie-from-devtools-paste
git switch master
git merge --squash jmann345/fix/recover-cookie-from-devtools-paste
git switch master
git merge --ff-only jmann345/fix/recover-cookie-from-devtools-paste
git switch master
git merge jmann345/fix/recover-cookie-from-devtools-paste
git push origin master
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
arduinohatesme/leetcode.nvim!229
No description provided.