Skip to content

Support parsing httponly cookies#135

Merged
dantleech merged 2 commits into
dantleech:masterfrom
aszenz:fix-httponly-cookies
Feb 10, 2026
Merged

Support parsing httponly cookies#135
dantleech merged 2 commits into
dantleech:masterfrom
aszenz:fix-httponly-cookies

Conversation

@aszenz

@aszenz aszenz commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

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).
;

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

Copy link
Copy Markdown
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
Copy Markdown
Owner

👍 just a minor improvement on the teset

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
@aszenz aszenz force-pushed the fix-httponly-cookies branch from f6764eb to 4c6f864 Compare February 10, 2026 10:03
@aszenz aszenz requested a review from dantleech February 10, 2026 10:03
@dantleech dantleech merged commit b23f3c5 into dantleech:master Feb 10, 2026
5 checks passed
@dantleech

Copy link
Copy Markdown
Owner

thanks, tagged a new version

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