Skip to content

Doesn't return a file with special characters %23, %2A, etc. #6523

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

Open
charlyalize opened this issue May 21, 2025 · 1 comment
Open

Doesn't return a file with special characters %23, %2A, etc. #6523

charlyalize opened this issue May 21, 2025 · 1 comment

Comments

@charlyalize
Copy link

Doesn't return a file with special characters %23, %2A, etc. I'm working on a Node.js project to download files with names like: normal_00dc038225ac0372_cpd_%2A%23%2A00936154844019_19619_19119_18-53-44_2025-05-20-019B0282-10063123-00000001.mp3

and Express can't find it.

Incoming request: GET /audios/2025/05/21/normal_00dc038225ac0372_cpd_%2A%23%2A00936154844019_19619_19119_18-53-44_2025-05-20-019B0282-10063123-00000001.mp3

and returns 404 notfound, the file exists at the correct path.

@krzysdz
Copy link
Contributor

krzysdz commented May 21, 2025

If you request /normal_00dc038225ac0372_cpd_%2A%23%2A00936154844019_19619_19119_18-53-44_2025-05-20-019B0282-10063123-00000001.mp3 then the server after decoding the URL will receive normal_00dc038225ac0372_cpd_*#*00936154844019_19619_19119_18-53-44_2025-05-20-019B0282-10063123-00000001.mp3. This is the result of URI/percent encoding (Wikipedia, RFC 3986)

If you have a file with % in name on disk, then you'll have to encode this character as %25 in URL. In JavaScript you can use encodeURIComponent to encode a single component of URI and decodeURIComponent to decode. % is a special character in URIs, because it is a marker of an encoded character.

You can check if I'm right by requesting /audios/2025/05/21/normal_00dc038225ac0372_cpd_%252A%2523%252A00936154844019_19619_19119_18-53-44_2025-05-20-019B0282-10063123-00000001.mp3 from your server, which should decode to the path that you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants