chromiumembedded / cef

Chromium Embedded Framework (CEF). A simple framework for embedding Chromium-based browsers in other applications.
https://bitbucket.org/chromiumembedded/cef/
Other
3.26k stars 456 forks source link

CefDownloadHandler Download Chinese name file garbled #3135

Open magreenblatt opened 3 years ago

magreenblatt commented 3 years ago

Original report by dingX wan (Bitbucket: Wanding, GitHub: Wanding).


The requested url is https://sz.jd.com/sz/api/productDetail/exportSummaryData.ajax, and the suggested_name file name is exportSummaryData.ajax. However, this is not the filename I wanted. I checked Content-Disposition, ��Ʒ�ſ�_���ݸ���_ȫ������_2021-05-25.xls, but it is a messy filename, probably because it contains Chinese

Content-disposition: attachment;charset=utf-8;filename=��Ʒ�ſ�_���ݸ���_ȫ������_2021-05-25.xls

Note that the MacOS CEF library does this, Windows CEF lib and google have the correct file name

magreenblatt commented 3 years ago

Original comment by dingX wan (Bitbucket: Wanding, GitHub: Wanding).


magreenblatt commented 3 years ago

Original comment by dingX wan (Bitbucket: Wanding, GitHub: Wanding).


This question has been bothering me for a long time. Has anyone encountered this kind of problem

magreenblatt commented 3 years ago

What CEF version? How does it behave in Google Chrome at the same version? It appears that you are not providing encoding information via the filename* directive as required.

magreenblatt commented 3 years ago

Original comment by dingX wan (Bitbucket: Wanding, GitHub: Wanding).


@{557058:2f2a2aee-b500-4023-9734-037e9897c3ab} But there is no problem with the file name downloaded from Google browser, Google downloads it is "商品概况_数据概览_全部渠道_2021-05-26 (1).xls". using CEF, it was called exportSummaryData.ajax. Maybe it has nothing to do with garbled code, because the Google debug window also shows the previous part of the Chinese garbled code, but it downloaded the file name is normal .This bug has nothing to do with the CEF version. It's been bothering me for a long time @ Marshall Greenblatt

magreenblatt commented 3 years ago

Original comment by dingX wan (Bitbucket: Wanding, GitHub: Wanding).


I wonder if it has something to do with the fact that its file is an Ajax request and happens to have Chinese in the filename

magreenblatt commented 3 years ago

Original comment by dingX wan (Bitbucket: Wanding, GitHub: Wanding).


@{557058:2f2a2aee-b500-4023-9734-037e9897c3ab}

 I've debugged the interface associated with downloading the CefDownloadHandler class

OnBeforeDownload(CefRefPtr browser, cefdownloadHandler, cefdownloadHandler)
CefRefPtr download_item,
const CefString& suggested_name,
CefRefPtr callback);

Suggested_name in MacOS CEF is “exportSummaryData.ajax", but in Windows CEF is "商品概况_数据概览_全部渠道_2021-06-26 (1).xls"

This has been a problem with all CEF releases, including the latest, and has bothered me for years

magreenblatt commented 3 years ago

Original comment by dingX wan (Bitbucket: Wanding, GitHub: Wanding).


@{557058:2f2a2aee-b500-4023-9734-037e9897c3ab} Thanks for your answers. I noticed a phenomenon. The POST request have the Content-Type field, because I found that the GET request does not have this field.This field sets the encoding format. I don't know if it's related to this bug

magreenblatt commented 3 years ago

Interesting that the wrong file name (“exportSummaryData.ajax”) only appears on MacOS. I’m not aware of any platform-specific code related to this in CEF. Can you run both the MacOS and Windows versions in a debugger and see if you can identify where the code differs?

magreenblatt commented 3 years ago

Original comment by dingX wan (Bitbucket: Wanding, GitHub: Wanding).


@{557058:2f2a2aee-b500-4023-9734-037e9897c3ab} I glad receive your answers. It is clear that it has nothing to do with the version, the Windows version is always fine, but the MacOS version is always wrong. The Windows team and I have not been able to understand the reason, and the preliminary conclusion should be the CEF kernel code problem. Moreover, in the official demo provided, the file name after downloading is different from Windows and MacOS. If you would like me to provide the address of the web page in question, including how to repeat the question, I would be happy to do so

magreenblatt commented 3 years ago

If you would like me to provide the address of the web page in question, including how to repeat the question, I would be happy to do so

That would help, thanks.

magreenblatt commented 3 years ago

Original comment by dingX wan (Bitbucket: Wanding, GitHub: Wanding).


@Marshall Greenblatt I don't think I can figure out why。 I think it's the file name encoding problem。

"\U0000fffd\U0000fffdƷ\U0000fffdſ\U0000fffd_\U0000fffd\U0000fffd\U0000fffdݸ\U0000fffd\U0000fffd\U0000fffd_ȫ\U0000fffd\U0000fffd\U0000fffd\U0000fffd\U0000fffd\U0000fffd_2021-07-19.xls"  I think the file name encoding is wrong, but I can't find how to solve it

magreenblatt commented 3 years ago

Original comment by dingX wan (Bitbucket: Wanding, GitHub: Wanding).


@Marshall Greenblatt I think the answer is to look at the file name encoding for Windows and MacOS

magreenblatt commented 3 years ago

Original changes by dingX wan (Bitbucket: Wanding, GitHub: Wanding).


magreenblatt commented 3 years ago

Original changes by dingX wan (Bitbucket: Wanding, GitHub: Wanding).


magreenblatt commented 1 year ago