Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion http.carp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ the type yourself, instead you can [parse](#parse) it.")
(fmt
"malformed samesite property in set-cookie, unknown value: %s"
&s)))))
(Result.Error (fmt "Unknown set-cookie property: %s" prop))))))
(Result.Success c)))))

(doc parse-set "parses a `Set-Cookie` form.")
(defn parse-set [s]
Expand Down
20 changes: 20 additions & 0 deletions test/http.carp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,26 @@
_ false)
"parse-set rejects malformed Expires date")

; -- Unknown Set-Cookie attributes are silently ignored (RFC 6265) --
(assert-true test
(match (Cookie.parse-set "id=abc; Partitioned")
(Result.Success c) (= (Cookie.name &c) "id")
_ false)
"parse-set ignores unknown attribute Partitioned")

(assert-true test
(match (Cookie.parse-set "id=abc; Priority=High")
(Result.Success c) (= (Cookie.value &c) "abc")
_ false)
"parse-set ignores unknown attribute Priority=High")

(assert-true test
(match (Cookie.parse-set
"id=abc; Path=/; Partitioned; Secure; Priority=High")
(Result.Success c) (and (= (Cookie.path &c) "/") @(Cookie.secure &c))
_ false)
"parse-set handles mix of known and unknown attributes")

; -- Cookie value containing '=' (e.g. base64 padding) --
(assert-true test
(match (Cookie.parse "session=YWJjZA==")
Expand Down
Loading