简体   繁体   中英

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.

Ex: I have certain filename like testing:testing1:testing2.csv .

Now when the Save As dialog pops up, I am seeing filename converted to

testing-testing1-testing2.csv for Chrome

and

testing_testing1_testing2.csv for Firefox .

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). If you want to make sure your application is compatible with Windows, keep that in mind.

These are the disallowed characters:

\\ / : * ? " < > |

Firefox & Chrome probably replace all of those by the dash / underscore.

The filename is merely a suggestion . RFC 2616 states that:

19.5.1 Content-Disposition

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. This usage is derived from the definition of Content-Disposition in RFC 1806 [35].

RFC 1806 further states that:

It is important that the receiving MUA not blindly use the suggested filename. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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