Skip to content

Cookies set on server are improperly escaped #11687

Closed
@howard36

Description

@howard36

Describe the bug

This load function in +page.server.ts sets a cookie with value "a/b":

export function load({cookies}: any) {
    cookies.set("test", `"a/b"`);
    return {};
}

But the value that's actually returned in the Set-Cookie header and saved in the browser is %22a%2Fb%22. This bug only happens when load is run on the server, not in the browser.

Reproduction

Code: https://codesandbox.io/p/devbox/sveltekit-cookie-issue-l3c2zc?file=%2Fsrc%2Froutes%2F%2Bpage.server.ts%3A4%2C2

Website: https://l3c2zc-5173.csb.app/

(The code is deployed on the website above, and visiting the website should set the incorrect cookie %22a%2Fb%22 in your browser)

Logs

No response

System Info

System:
    OS: Linux 5.13 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz
    Memory: 26.26 GB / 30.85 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 18.14.0 - ~/.nvm/versions/node/v18.14.0/bin/node
    npm: 9.3.1 - ~/.nvm/versions/node/v18.14.0/bin/npm
  Browsers:
    Chrome: 120.0.6099.234

Severity

serious, but I can work around it

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions