jshttp / content-disposition

Create and parse HTTP Content-Disposition header
MIT License
224 stars 43 forks source link

Problems with supporting Cyrillic alphabet #46

Open AIHI opened 1 year ago

AIHI commented 1 year ago

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

Video

dougwilson commented 1 year ago

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!

AIHI commented 1 year ago

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

dougwilson commented 1 year ago

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`
AIHI commented 1 year ago

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

dougwilson commented 1 year ago

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.