content-disposition icon indicating copy to clipboard operation
content-disposition copied to clipboard

Problems with supporting Cyrillic alphabet

Open AIHI opened this issue 2 years ago • 5 comments

According to my observations, if the Cyrillic alphabet has more than 42-43 characters, the library starts to work incorrectly

Video

AIHI avatar Apr 14 '23 19:04 AIHI

Hello, and thank you for your report. Can you help by providing a reproduction of the issue you are referring to? Just paste the code in here that shows the usage of this module and also please show what you are expecting the output to look like. Thank you!

dougwilson avatar Apr 14 '23 19:04 dougwilson

Hello! Thank you for your quick reaction to my question.

res.setHeader( 'Content-Disposition', contentDisposition("Приказ.Минобрнауки.2009г.Об.утвержденииф.pdf", { type: 'attachment', }) )

Video: 01:40 - 01:46 Expect to receive this file name when downloading: Приказ.Минобрнауки.2009г.Об.утвержденииф.pdf

And we get this 6438b5fbbca27100219cc149

AIHI avatar Apr 14 '23 20:04 AIHI

Sorry for your trouble. What web browser is this happening in? As far as I can tell, the content-disposition header generated is following RFC 6266. Besides the web browser so I can reproduce the issue, do you have an example of what the content-disposition header you are expecting to see it?

Here is what this module outputs for your given input. It seems unclear where exactly 6438b5fbbca27100219cc149 would come from.

> contentDisposition("Приказ.Минобрнауки.2009г.Об.утвержденииф.pdf", { type: 'attachment', })
`attachment; filename="??????.???????????.2009?.??.????????????.pdf"; filename*=UTF-8''%D0%9F%D1%80%D0%B8%D0%BA%D0%B0%D0
%B7.%D0%9C%D0%B8%D0%BD%D0%BE%D0%B1%D1%80%D0%BD%D0%B0%D1%83%D0%BA%D0%B8.2009%D0%B3.%D0%9E%D0%B1.%D1%83%D1%82%D0%B2%D0%B5%
D1%80%D0%B6%D0%B4%D0%B5%D0%BD%D0%B8%D0%B8%D1%84.pdf`

dougwilson avatar Apr 14 '23 20:04 dougwilson

In this example I use Safari v.16.4.1 (17615.1.26.101.10, 17615)

6438b5fbbca27100219cc149 — this id in MongoDB

The file is received by the link of the /api/some_path/6438b5fbbca27100219cc149

AIHI avatar Apr 14 '23 21:04 AIHI

Thank you. Unfortunately I don't have access to Safari. If you or something can see what is wrong, you are welcome to make a pull request to fix.

dougwilson avatar Apr 14 '23 21:04 dougwilson

I think this issue would need more details for us to address. If you could do an example code snippet like Doug did above but which shows what you expect and what you get, that would be awesome. Until then I am going to close this, but will re-open if we can get a more clear bug report.

wesleytodd avatar Mar 05 '25 14:03 wesleytodd