Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Cannot create cookie with name containing some characters #33619

Copy link
Copy link
Closed
@trvrnrth

Description

@trvrnrth
Issue body actions

Symfony version(s) affected: All

Description
When creating a non-raw Cookie, it is impossible to provide a name that contains characters matching the regex class [=,; \t\r\n\013\014] even though __toString later performs a urlencode to sanitise this field for output.

How to reproduce
$cookie = new Cookie('yes=please');

Possible Solution
I would expect for it to be permissible to supply any value for the name in the same way that you can for the value in non-raw mode by performing the character validation only in raw mode:

if ($raw && preg_match("/[=,; \t\r\n\013\014]/", $name)) {
    throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name));
}

Additional context
It is possible to work around this issue by creating a Cookie in raw mode, but this places additional burden on the implementing application to take care of encoding both the name and value at all times. In my particular use case I am also making use of the Illuminate Cookie Jar forget method which does not expose the ability to operate in raw mode.

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.