Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-11002] Behaviour difference in HTTPCookie.isSecure #3301

Open
pushkarnk opened this issue Jun 24, 2019 · 0 comments · May be fixed by #4822
Open

[SR-11002] Behaviour difference in HTTPCookie.isSecure #3301

pushkarnk opened this issue Jun 24, 2019 · 0 comments · May be fixed by #4822

Comments

@pushkarnk
Copy link
Collaborator

Previous ID SR-11002
Radar None
Original Reporter @pushkarnk
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: acf09b4524174255f39bf28598341655

Issue Description:

On macOS, one can set the `isSecure` attribute of an HTTPCookie by simply having an entry for `HTTPCookiePropertyKey.secure` in the dictionary that is passed to `init(properties: [HTTPCookiePropertyKey : Any])` initialiser.

import Foundation


let attributes: [HTTPCookiePropertyKey: Any] = [
    HTTPCookiePropertyKey.name : "name",
    HTTPCookiePropertyKey.value: "value",
    HTTPCookiePropertyKey.domain: "domain",
    HTTPCookiePropertyKey.path: "path",
    HTTPCookiePropertyKey.secure: "true",
    //HTTPCookiePropertyKey.secure: "false", -- isSecure is TRUE
    //HTTPCookiePropertyKey.secure: true, -- isSecure is TRUE
    //HTTPCookiePropertyKey.secure: false, -- isSecure is TRUE
]


HTTPCookie(properties: attributes)
 

The only way to not have `isSecure` set to `true` is to not have an entry for the `HTTPCookiePropertyKey` in the dictionary.

On Linux, we have a different behaviour. There, the `isSecure` attribute is true if and only if the value if of the type String, and is not empty. It is false otherwise.

See this line of code: https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/HTTPCookie.swift#L287

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
@xinus xinus linked a pull request Sep 19, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant