remix icon indicating copy to clipboard operation
remix copied to clipboard

Redirecting to utf8 URLs causes an internal server error

Open tmcw opened this issue 2 years ago • 1 comments

What version of Remix are you using?

2.1.0

Are all your remix dependencies & dev-dependencies using the same version?

  • [X] Yes

Steps to Reproduce

In a loader, call something like

throw redirect(encodeURI(`/ಠ`));

Expected Behavior

It redirects to the URL, /ಠ

Actual Behavior

You get an internal server error:

Unexpected Server Error

TypeError: Cannot convert argument to a ByteString because the character at index 15 has a value of 3232 which is greater than 255.

This is, fwiw, kind of reasonable - the Location HTTP header does require that its value is a ASCII.

However, I think at this level of interface, this is pretty unexpected: you're redirecting to a URL, not setting a Location header. It makes sense, I think, to call internally encodeURI() to escape any non-ASCII characters in the redirect target, rather than expecting the API consumer to do that anywhere that a redirect is used.

tmcw avatar Oct 26 '23 15:10 tmcw

@tmcw Tested this on the last remix version, seems to be working fine, and I'm being redirected to /ಠ Is this fixed for you as well ?

machour avatar May 17 '24 13:05 machour

This issue has been automatically closed because we haven't received a response from the original author 🙈. This automation helps keep the issue tracker clean from issues that are unactionable. Please reach out if you have more information for us! 🙂

github-actions[bot] avatar May 27 '24 14:05 github-actions[bot]

Faced similar issue. OP's post states the issue and fix, it's just labeled incorrectly

This will create an error

throw redirect(`/ಠ`);

This will fix it

throw redirect(encodeURI(`/ಠ`));

Butter1v9 avatar Oct 08 '24 14:10 Butter1v9