简体   繁体   English

Chrome,Firefox在其文件保存对话框中分别将“:”转换为“-”和“ _”

[英]Chrome, Firefox converting “:” to “-” and “_” respectively in their file save dialog

I am trying to save a file using FileSaver library which will save the file using Chrome's and Firefox's Save As dialog. 我正在尝试使用FileSaver库保存文件,该库将使用ChromeFirefox的“ Save As对话框保存文件。

Ex: I have certain filename like testing:testing1:testing2.csv . 例如:我有某些文件名,例如testing:testing1:testing2.csv

Now when the Save As dialog pops up, I am seeing filename converted to 现在,当Save As对话框弹出时,我看到文件名已转换为

testing-testing1-testing2.csv for Chrome 用于Chrome的 testing-testing1-testing2.csv

and

testing_testing1_testing2.csv for Firefox . 用于Firefox的 testing_testing1_testing2.csv

Is there any way we can suppress this conversion of characters? 有什么办法可以抑制这种字符转换?

Thanks 谢谢

No. 没有。

File names can't contain, among other characters, the colon : (On Windows machines). 文件名中不能包含冒号:(在Windows机器上)。 If you want to make sure your application is compatible with Windows, keep that in mind. 如果要确保您的应用程序与Windows兼容,请记住这一点。

These are the disallowed characters: 这些是不允许的字符:

\\ / : * ? \\ / * " < > | < > |

Firefox & Chrome probably replace all of those by the dash / underscore. Firefox和Chrome可能用破折号/下划线代替了所有这些。

The filename is merely a suggestion . 文件名只是一个建议 RFC 2616 states that: RFC 2616指出:

19.5.1 Content-Disposition 19.5.1内容处置

The Content-Disposition response-header field has been proposed as a means for the origin server to suggest a default filename if the user requests that the content is saved to a file. 已经提出了Content-Disposition响应标头字段,作为原始服务器在用户请求将内容保存到文件时建议默认文件名的一种方式。 This usage is derived from the definition of Content-Disposition in RFC 1806 [35]. 这种用法源自RFC 1806 [35]中Content-Disposition的定义。

RFC 1806 further states that: RFC 1806进一步指出:

It is important that the receiving MUA not blindly use the suggested filename. 接收方MUA请勿盲目使用建议的文件名,这一点很重要。 The suggested filename SHOULD be checked (and possibly changed) to see that it conforms to local filesystem conventions, does not overwrite an existing file, and does not present a security problem (see Security Considerations below). 建议的文件名应进行检查(并可能更改),以确保其符合本地文件系统约定,不覆盖现有文件并且不存在安全性问题(请参阅下面的安全注意事项)。

Long story short, different file systems have different restrictions on filenames . 长话短说, 不同的文件系统对文件名有不同的限制 The browser is free to fix the filename if it cannot be used as-is. 如果不能按原样使用浏览器,则可以自由修复文件名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM