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

[Bug]: Cookies unable to encode UTF-8 strings #1282

Closed
1 of 12 tasks
shamsup opened this issue Dec 30, 2021 · 2 comments
Closed
1 of 12 tasks

[Bug]: Cookies unable to encode UTF-8 strings #1282

shamsup opened this issue Dec 30, 2021 · 2 comments
Labels
bug Something isn't working feat:cookies

Comments

@shamsup
Copy link
Contributor

shamsup commented Dec 30, 2021

Which Remix packages are impacted?

  • remix (Remix core)
  • create-remix
  • @remix-run/architect
  • @remix-run/cloudflare-workers
  • @remix-run/dev
  • @remix-run/express
  • @remix-run/netlify
  • @remix-run/node
  • @remix-run/react
  • @remix-run/serve
  • @remix-run/server-runtime
  • @remix-run/vercel

What version of Remix are you using?

any

What version of Node are you using? Minimum supported version is 14.

14+

Steps to Reproduce

from sergiodxa/remix-auth#115 (@thangngoc89)

Try to encode a cookie with a UTF-16 string - ie "Nguyễn Văn A"

Essentially btoa expects a string to be binary, so encountering characters that are UTF-16 encoded with more than 8 bits will throw an error. This is well-documented by Mozilla. In JSON and JavaScript, strings are UTF-16, so representing the characters is not an issue. However, this means that JSON.stringifying a string does not make it safe for btoa.

Expected Behavior

Cookie properly set 😎

Actual Behavior

Cookie is not set and error is swallowed

@shamsup shamsup added the bug Something isn't working label Dec 30, 2021
@shamsup shamsup changed the title [Bug]: Cookies unable to encode UTF-16 strings [Bug]: Cookies unable to encode UTF-8 strings Dec 30, 2021
@nimaa77
Copy link

nimaa77 commented Dec 30, 2021

some one missed reading this section while they were developing remix
https://developer.mozilla.org/en-US/docs/Web/API/btoa#unicode_strings

@machour
Copy link
Collaborator

machour commented Apr 7, 2022

Fixed in #2257 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feat:cookies
Projects
None yet
Development

No branches or pull requests

3 participants