Error: filename must not contain illegal characters

Absolute paths, empty paths, and paths containing back-references ( ../ ) will cause an error.

The attached test extension tries to download a blob into “.Test.txt”
Result:
Error: filename must not contain illegal characters

The leading dot is the problem.
Apparently, Firefox interprets the dot as meaning “current directory”, and that’s not allowed in a filename passed to downloads.download()

Questions:

  • Is there a way to create a dot file with downloads.download() ?
  • Are there other illegal characters not mentioned in the downloads.download() documentation?

downloadblob.zip (4.1 KB)

Filenames with a leading dot are deliberately forbidden.

https://searchfox.org/mozilla-central/source/uriloader/exthandler/nsExternalHelperAppService.cpp

// We don’t want to save hidden files starting with a dot, so remove any
// leading periods. This is done first, so that the remainder will be
// treated as the filename, and not an extension.
// Also, Windows ignores terminating dots. So we have to as well, so
// that our security checks do “the right thing”
fileName.Trim(".");