diff options
author | Moonchild <moonchild@palemoon.org> | 2020-07-29 01:21:13 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-07-29 01:21:13 +0000 |
commit | 3b0123aa12675decc11332704997e29a819eb8ff (patch) | |
tree | fca56977877dae912f340f41ae12d828c7d17d68 /netwerk | |
parent | 08fb2f306856948ecc71974dd98c0a6d78df25aa (diff) | |
download | uxp-3b0123aa12675decc11332704997e29a819eb8ff.tar.gz |
[network/dom] Improve sanitization of download filenames.
Diffstat (limited to 'netwerk')
-rw-r--r-- | netwerk/base/nsBaseChannel.cpp | 6 | ||||
-rw-r--r-- | netwerk/protocol/http/HttpBaseChannel.cpp | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/netwerk/base/nsBaseChannel.cpp b/netwerk/base/nsBaseChannel.cpp index 2575fac046..51caa546eb 100644 --- a/netwerk/base/nsBaseChannel.cpp +++ b/netwerk/base/nsBaseChannel.cpp @@ -579,6 +579,12 @@ NS_IMETHODIMP nsBaseChannel::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; } diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index a53022f71f..bf8e17537a 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -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; } |