This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jaswdr
Recipients jaswdr, ra1nb0w
Date 2021-05-12.17:57:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1620842258.76.0.439860089121.issue44104@roundup.psfhosted.org>
In-reply-to
Content
Simple example to reproduce the issue:

from http import cookies
C = cookies.SimpleCookie()
C["ys-api/mpegts/service"] = "blabla"
print(C.output())

@ra1nb0w so far as I have found [1][2], the "/" not a valid character for the Cookie name, [3] defines the list of valid characters and [4] is where the exception is raised, I also found that even with the RFC browsers have different rules for the Cookie name definitions, this could be reason why Python has, for example, the ":" character in the list.

My conclusion is that the rule for the cookie name is not well-defined, there are some ambiguities here and there, but if we consider purely this case and the RFC, the "/" still is not a valid character for the cookie name, so I guess the best option for you is to filter it out any http.cookies.CookieError that happen.

[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes
[2] https://datatracker.ietf.org/doc/html/rfc2616#section-2.2
[3] https://github.com/python/cpython/blob/main/Lib/http/cookies.py#L162
[4] https://github.com/python/cpython/blob/main/Lib/http/cookies.py#L353
History
Date User Action Args
2021-05-12 17:57:38jaswdrsetrecipients: + jaswdr, ra1nb0w
2021-05-12 17:57:38jaswdrsetmessageid: <1620842258.76.0.439860089121.issue44104@roundup.psfhosted.org>
2021-05-12 17:57:38jaswdrlinkissue44104 messages
2021-05-12 17:57:38jaswdrcreate