CefDownloadHandler Download Chinese name file garbled

Issue #3135 new
dingX wan created an issue

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

Comments (14)

  1. dingX wan reporter

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

  2. Marshall Greenblatt

    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.

  3. dingX wan reporter

    @Marshall Greenblatt 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

  4. dingX wan reporter

    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

  5. dingX wan reporter

    @Marshall Greenblatt

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

    OnBeforeDownload(CefRefPtr<CefBrowser> browser, cefdownloadHandler, cefdownloadHandler)
    CefRefPtr<CefDownloadItem> download_item,
    const CefString& suggested_name,
    CefRefPtr<CefBeforeDownloadCallback> 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

  6. dingX wan reporter

    @Marshall Greenblatt 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

  7. Marshall Greenblatt

    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?

  8. dingX wan reporter

    @Marshall Greenblatt 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

  9. Marshall Greenblatt

    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.

  10. dingX wan reporter

    @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

  11. dingX wan reporter

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

  12. Log in to comment