Skip to content

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

@pushkarnk

Description

@pushkarnk
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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions