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

fix(remix-server-runtime): fix invalid character error in cookie serialize #1290

Closed
wants to merge 4 commits into from

Conversation

nimaa77
Copy link

@nimaa77 nimaa77 commented Dec 30, 2021

Description

you save a cookie that contains utf-8 characters as it's value, you don't get the right content after reading the cookie.
this is because atob and btoa function that used inside cookie module and these functions don't support utf-8.

as MDN suggested in their docs, you can convert the utf8 content into binary string and then pass it to btoa function and vice versa for ...

this is what this Pull Request is all about, fixing the issue with saving a cookie with utf8 text content

How to reproduce

https://codesandbox.io/s/dazzling-monad-0wt38?file=/app/routes/index.jsx

closes: #1282

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Dec 30, 2021

Hi @nimaa77,

Welcome, and thank you for contributing to Remix!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your name to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run.

Thanks!

- The Remix team

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Dec 30, 2021

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@shamsup
Copy link
Contributor

shamsup commented Dec 30, 2021

This should close #1282 instead of 128 ❤️

@nimaa77
Copy link
Author

nimaa77 commented Dec 30, 2021

ah, my bad

@shamsup thanks man

@nimaa77 nimaa77 changed the title WIP: Feature/allow utf8 cookies FIX: utf8 cookie problem Dec 30, 2021
@nimaa77 nimaa77 changed the title FIX: utf8 cookie problem FIX utf8 text content cookie problem Dec 30, 2021
@ryanflorence
Copy link
Member

Binary data is out of my wheelhouse, @mjackson can you take a look at this? If you approve it I'll deal w/ the merge conflicts and merge it in.

@rphlmr
Copy link
Contributor

rphlmr commented Feb 11, 2022

Hi @nimaa77

A user of our lib, (remix-auth-supabase), needing Korean char encoding, encounters a bug (mitchelvanbever/remix-auth-supabase#15) and points me to your pull request.

We both console.log our session cookie and face an other issue : the size increase a lot (≈ x2) and trigger cookie max size limit (4096 bytes)


With current latest remix version : 3204 bytes

console.log("before", btoa(JSON.stringify(value)))

before_patch

With the fix : 6404 bytes

 console.log("after", btoa(converted))

after_ptach

I could deal with it and open a discussion with our main maintainer (to keep only minimum needed session datas).
Just here to give a feedback 😇

@rphlmr
Copy link
Contributor

rphlmr commented Feb 11, 2022

What do you think using encodeURIComponent and decodeURIComponent @nimaa77 ?
(NB : I'm not a specialist)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent

I try this and unit test seems still ok :

function encodeData(value) {
  let stringified = JSON.stringify(value);
  let converted = encodeURIComponent(stringified);
  return btoa(converted);
}

function decodeData(value) {
  try {
    let decodedData = atob(value);
    let converted = decodeURIComponent(decodedData);
    return JSON.parse(converted);
  } catch (error) {
    return {};
  }
}

NB : the output value will not be a json but an escaped string

Before :

{"sb:session":{"provider_token":"9d9l4spm

After (decodeURIComponent):

%7B%22sb%3Asession%22%3A%7B%22provider_token%22%3A%229d9

@chenc041
Copy link
Contributor

Why not set encoding to UTf8 in Buffer. from?
like this Buffer.from(a, "base64").toString() ?

@B4TT3RY
Copy link

B4TT3RY commented Feb 18, 2022

Buffer.from(originText, 'utf8').toString('base64')
Buffer.from(base64EncodedText, 'base64').toString('utf8')

This seems to work.

image
image
image

@chenc041
Copy link
Contributor

Buffer.from(originText, 'utf8').toString('base64')
Buffer.from(base64EncodedText, 'base64').toString('utf8')

This seems to work.

image image image

Yes, and I also submit a pr about this, and I think would better resolve this in the root
cookie serialize

@shamsup
Copy link
Contributor

shamsup commented Feb 18, 2022

Buffer is a node api, and isn't available in Cloudflare Workers/Pages

This would work if the cookie code were environment specific, but it looks like it is shared for every platform. Changing the implementation in the node-specific atob and btoa implementations makes sense to get it working in node environments, but this diverges compatibility at another level between node and Cloudflare and similar environments. UTF-8 in cookies would work in node, but would break moving an app to a different target platform.

@aiji42
Copy link
Contributor

aiji42 commented Mar 9, 2022

As @rphlmr mentions, conversions using toBinary can be quite large in size. Using encodeURIComponent and decodeURIComponent can reduce the size slightly from toBinary, but still It is still insufficient. I suggest using escape and unescape in conjunction with them.

Here are the results of an actual experiment using Google auth data for encoding.

# original string
{"access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNjQ2ODA0NTUzLCJzdWIiOiJhN2UxNjUyNC0wZTU4LTQ3M2QtOTU3OC1kYjU5OGU0ZTA4NmEiLCJlbWFpbCI6ImFpamk0MkBnbWFpbC5jb20iLCJwaG9uZSI6IiIsImFwcF9tZXRhZGF0YSI6eyJwcm92aWRlciI6Imdvb2dsZSIsInByb3ZpZGVycyI6WyJnb29nbGUiXX0sInVzZXJfbWV0YWRhdGEiOnsiYXZhdGFyX3VybCI6Imh0dHBzOi8vbGgzLmdvb2dsZXVzZXJjb250ZW50LmNvbS9hL0FBVFhBSnlvMWlfaGNDRS1XVVpJZVhkOFFncDJPTF9GVnFLVUIzYlJxYnJaPXM5Ni1jIiwiZW1haWwiOiJhaWppNDJAZ21haWwuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImZ1bGxfbmFtZSI6IuS4iuWztuaEm-WPsiIsImlzcyI6Imh0dHBzOi8vd3d3Lmdvb2dsZWFwaXMuY29tL3VzZXJpbmZvL3YyL21lIiwibmFtZSI6IuS4iuWztuaEm-WPsiIsInBpY3R1cmUiOiJodHRwczovL2xoMy5nb29nbGV1c2VyY29udGVudC5jb20vYS9BQVRYQUp5bzFpX2hjQ0UtV1VaSWVYZDhRZ3AyT0xfRlZxS1VCM2JScWJyWj1zOTYtYyIsInByb3ZpZGVyX2lkIjoiMTA0OTkwNzE0OTI3NzEwMDgxMTM4Iiwic3ViIjoiMTA0OTkwNzE0OTI3NzEwMDgxMTM4In0sInJvbGUiOiJhdXRoZW50aWNhdGVkIn0.ui_GPNjLOaMEc1hTZLCodHmD01CrLT_eKH0fudhEBrc","token_type":"bearer","expires_in":3600,"refresh_token":"xxxxxxxxxxxxxxxxxxxxxx","user":{"id":"a7e16524-0e58-473d-9578-db598e4e086a","aud":"authenticated","role":"authenticated","email":"aiji42@gmail.com","email_confirmed_at":"2022-03-09T04:40:20.529266Z","phone":"","confirmed_at":"2022-03-09T04:40:20.529266Z","last_sign_in_at":"2022-03-09T04:42:32.780892Z","app_metadata":{"provider":"google","providers":["google"]},"user_metadata":{"avatar_url":"https://lh3.googleusercontent.com/a/AATXAJyo1i_hcCE-WUZIeXd8Qgp2OL_FVqKUB3bRqbrZ=s96-c","email":"aiji42@gmail.com","email_verified":true,"full_name":"上島愛史","iss":"https://www.googleapis.com/userinfo/v2/me","name":"上島愛史","picture":"https://lh3.googleusercontent.com/a/AATXAJyo1i_hcCE-WUZIeXd8Qgp2OL_FVqKUB3bRqbrZ=s96-c","provider_id":"104990714927710081138","sub":"104990714927710081138"},"identities":[{"id":"104990714927710081138","user_id":"a7e16524-0e58-473d-9578-db598e4e086a","identity_data":{"avatar_url":"https://lh3.googleusercontent.com/a/AATXAJyo1i_hcCE-WUZIeXd8Qgp2OL_FVqKUB3bRqbrZ=s96-c","email":"aiji42@gmail.com","email_verified":true,"full_name":"上島愛史","iss":"https://www.googleapis.com/userinfo/v2/me","name":"上島愛史","picture":"https://lh3.googleusercontent.com/a/AATXAJyo1i_hcCE-WUZIeXd8Qgp2OL_FVqKUB3bRqbrZ=s96-c","provider_id":"104990714927710081138","sub":"104990714927710081138"},"provider":"google","last_sign_in_at":"2022-03-09T04:40:20.527146Z","created_at":"2022-03-09T04:40:20.527202Z","updated_at":"2022-03-09T04:40:20.527207Z"}],"created_at":"2022-03-09T04:40:20.51995Z","updated_at":"2022-03-09T04:42:33.233859Z"},"expires_at":1646804553}

# using toBinary; btoa(toBinary(value))
ewAiAGEAYwBjAGUAcwBzAF8AdABv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ZXJfaWQiOiI0ZmJmMjM1Yy04MjBkLTRlYTQtOGQ1MS02MDNkZTM1ZDJkYTEiLCJpZGVudGl0eV9kYXRhIjp7ImF2YXRhcl91cmwiOiJodHRwczovL2xoMy5nb29nbGV1c2VyY29udGVudC5jb20vYS9BQVRYQUp5NmVVTFNMVWcwY2w1eHpXTXE5bVJZSWtlamExNURSRDVRQ1pTTz1zOTYtYyIsImVtYWlsIjoidWVqaW1hLmFpamlAYS10bS5jby5qcCIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJmdWxsX25hbWUiOiLkuIrls7bmhJvlj7IiLCJpc3MiOiJodHRwczovL3d3dy5nb29nbGVhcGlzLmNvbS91c2VyaW5mby92Mi9tZSIsIm5hbWUiOiLkuIrls7bmhJvlj7IiLCJwaWN0dXJlIjoiaHR0cHM6Ly9saDMuZ29vZ2xldXNlcmNvbnRlbnQuY29tL2EvQUFUWEFKeTZlVUxTTFVnMGNsNXh6V01xOW1SWUlrZWphMTVEUkQ1UUNaU089czk2LWMiLCJwcm92aWRlcl9pZCI6IjEwOTQ3ODAzNjgzNTY4NTQ2OTY0MCIsInN1YiI6IjEwOTQ3ODAzNjgzNTY4NTQ2OTY0MCJ9LCJwcm92aWRlciI6Imdvb2dsZSIsImxhc3Rfc2lnbl9pbl9hdCI6IjIwMjItMDMtMDhUMDE6NDI6NDQuNTg3NzQ4WiIsImNyZWF0ZWRfYXQiOiIyMDIyLTAzLTA4VDAxOjQyOjQ0LjU4Nzc4NFoiLCJ1cGRhdGVkX2F0IjoiMjAyMi0wMy0wOFQwMTo0Mjo0NC41OCwiY3JlYXRlZF9hdCI6IjIwMjItMDMtMDhUMDE6NDI6NDQuNTgyMjQ4WiIsInVwZGF0ZWRfYXQiOiIyMDIyLTAzLTA4VDA2OjA4OjU5LjE0MjAzMloifSwiZXhwaXJlc19hdCI6MTY0NjcyMzMzOX0=
# .length === 3504



# FYI: using btoa with non-ascii characters replaced by another ascii string (same number of characters)
eyJhY2Nlc3Nf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VQwNDo0MDoyMC41MjcyMDJaIiwidXBkYXRlZF9hdCI6IjIwMjItMDMtMDlUMDQ6NDA6MjAuNTI3MjA3WiJ9XSwiY3JlYXRlZF9hdCI6IjIwMjItMDMtMDlUMDQ6NDA6MjAuNTE5OTVaIiwidXBkYXRlZF9hdCI6IjIwMjItMDMtMDlUMDQ6NDI6MzMuMjMzODU5WiJ9LCJleHBpcmVzX2F0IjoxNjQ2ODA0NTUzfQ==
# .length === 3432

Using unescape, only non-ascii characters can be replaced and applied to btoa, thus reducing its size.

スクリーンショット 2022-03-09 午後1 59 54

Although escape and unescape are defined in Annex B and are not recommended for use (they have not been removed from the web standards), they are currently supported in all runtimes and are unlikely to be deprecated anytime soon. If the Remix community refuses to use it, there are polyfills defined in core-js those can be used as an alternative.

I didn't know this PR existed, so I created another one (#2257). I'll leave it up to you guys to decide if @nimaa77 will continue to respond here or merge mine.

@machour
Copy link
Collaborator

machour commented Mar 20, 2022

@nimaa77 Could you please fix conflicts so that this PR can be properly reviewed by the team? 🙏🏼

@machour machour added the needs-response We need a response from the original author about this issue/PR label Mar 20, 2022
@mjackson
Copy link
Member

Thanks for the PR, @nimaa77! And thank you for the additional PR and comments, @aiji42. I think I prefer the approach used in #2257 because the end result will be smaller. I'll follow up there.

@MichaelDeBoey MichaelDeBoey changed the title FIX utf8 text content cookie problem fix(remix-server-runtime): fix invalid character error in cookie serialize Mar 28, 2022
@MichaelDeBoey
Copy link
Member

Closing this, as we're fixing this in #2257 (see @mjackson's #1290 (comment))

@MichaelDeBoey MichaelDeBoey added duplicate This issue or pull request already exists and removed needs-response We need a response from the original author about this issue/PR labels Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.