зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1637745. r=Gijs,necko-reviewers,mayhemer
Differential Revision: https://phabricator.services.mozilla.com/D80345
This commit is contained in:
Родитель
f07c0832e3
Коммит
9717edb569
|
@ -605,6 +605,8 @@ void nsDocShellLoadState::SetTypeHint(const nsCString& aTypeHint) {
|
|||
const nsString& nsDocShellLoadState::FileName() const { return mFileName; }
|
||||
|
||||
void nsDocShellLoadState::SetFileName(const nsAString& aFileName) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(aFileName.FindChar(char16_t(0)) == kNotFound,
|
||||
"The filename should never contain null characters");
|
||||
mFileName = aFileName;
|
||||
}
|
||||
|
||||
|
|
|
@ -5258,6 +5258,11 @@ void nsContentUtils::TriggerLink(nsIContent* aContent, nsIURI* aLinkURI,
|
|||
nsCOMPtr<nsIPrincipal> triggeringPrincipal = aContent->NodePrincipal();
|
||||
nsCOMPtr<nsIContentSecurityPolicy> csp = aContent->GetCsp();
|
||||
|
||||
// Sanitize fileNames containing null characters by replacing them with
|
||||
// underscores.
|
||||
if (!fileName.IsVoid()) {
|
||||
fileName.ReplaceChar(char16_t(0), '_');
|
||||
}
|
||||
nsDocShell::Cast(docShell)->OnLinkClick(
|
||||
aContent, aLinkURI, fileName.IsVoid() ? aTargetSpec : EmptyString(),
|
||||
fileName, nullptr, nullptr, UserActivation::IsHandlingUserInput(),
|
||||
|
|
|
@ -604,6 +604,12 @@ nsBaseChannel::SetContentDispositionFilename(
|
|||
const nsAString& aContentDispositionFilename) {
|
||||
mContentDispositionFilename =
|
||||
MakeUnique<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;
|
||||
}
|
||||
|
||||
|
|
|
@ -701,6 +701,12 @@ HttpBaseChannel::SetContentDispositionFilename(
|
|||
const nsAString& aContentDispositionFilename) {
|
||||
mContentDispositionFilename =
|
||||
MakeUnique<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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1230,6 +1230,7 @@ nsExternalAppHandler::nsExternalAppHandler(
|
|||
// code sanitization in DownloadPaths.jsm
|
||||
mSuggestedFileName.ReplaceChar(KNOWN_PATH_SEPARATORS, '_');
|
||||
mSuggestedFileName.ReplaceChar(FILE_ILLEGAL_CHARACTERS, ' ');
|
||||
mSuggestedFileName.ReplaceChar(char16_t(0), '_');
|
||||
mTempFileExtension.ReplaceChar(KNOWN_PATH_SEPARATORS, '_');
|
||||
mTempFileExtension.ReplaceChar(FILE_ILLEGAL_CHARACTERS, ' ');
|
||||
|
||||
|
@ -2520,6 +2521,8 @@ NS_IMETHODIMP nsExternalHelperAppService::GetFromTypeAndExtension(
|
|||
nsIMIMEInfo** _retval) {
|
||||
MOZ_ASSERT(!aMIMEType.IsEmpty() || !aFileExt.IsEmpty(),
|
||||
"Give me something to work with");
|
||||
MOZ_DIAGNOSTIC_ASSERT(aFileExt.FindChar('\0') == kNotFound,
|
||||
"The extension should never contain null characters");
|
||||
LOG(("Getting mimeinfo from type '%s' ext '%s'\n",
|
||||
PromiseFlatCString(aMIMEType).get(),
|
||||
PromiseFlatCString(aFileExt).get()));
|
||||
|
|
Загрузка…
Ссылка в новой задаче