Skip to content

Support parsing httponly cookies#135

Open
aszenz wants to merge 2 commits intodantleech:masterfrom
aszenz:fix-httponly-cookies
Open

Support parsing httponly cookies#135
aszenz wants to merge 2 commits intodantleech:masterfrom
aszenz:fix-httponly-cookies

Conversation

@aszenz
Copy link

@aszenz aszenz commented Feb 6, 2026

Fixes #133

Adds support for parsing cookies with #HttpOnly_ prefix according to the Netscape cookie file format specification.

See: https://curl.se/docs/http-cookies.html

This test demonstrates the bug where cookies with the #HttpOnly_
prefix are incorrectly ignored. According to the Netscape cookie
file format specification, lines starting with #HttpOnly_ should
be parsed as cookies with the HttpOnly attribute set.

See: https://curl.se/docs/http-cookies.html

Currently fails: Expected 3 cookies (2 httponly + 1 regular) but
only finds 1 (the regular cookie).
Parse cookies with #HttpOnly_ prefix according to the Netscape
cookie file format specification. Previously, all lines starting
with # were treated as comments, but lines starting with #HttpOnly_
indicate cookies with the HttpOnly attribute set.

The fix:
- Detects #HttpOnly_ prefix and strips it before parsing
- Adds httponly attribute to the cookie string
- Continues to treat regular # lines as comments

See: https://curl.se/docs/http-cookies.html

Fixes dantleech#133
;

$path = $this->workspace()->path('httponly_cookies.txt');
file_put_contents($path, $cookies);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify this to $this->workspace()->put('httponly_cookies.txt', $cookies)

@dantleech
Copy link
Owner

👍 just a minor improvement on the teset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support parsing httponly cookies

2 participants