[network/dom] Improve sanitization of download filenames.

This commit is contained in:
Moonchild 2020-07-29 01:21:13 +00:00 committed by Roy Tam
commit 52c03190ee
4 changed files with 26 additions and 3 deletions

View file

@ -562,6 +562,12 @@ NS_IMETHODIMP
HttpBaseChannel::SetContentDispositionFilename(const nsAString& aContentDispositionFilename)
{
mContentDispositionFilename = new nsString(aContentDispositionFilename);
// For safety reasons ensure the filename doesn't contain null characters and
// replace them with underscores. We may later pass the extension to system
// MIME APIs that expect null terminated strings.
mContentDispositionFilename->ReplaceChar(char16_t(0), '_');
return NS_OK;
}