mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-12-27 20:30:39 +00:00
#616: M1658214 M1637745 M1648372
This commit is contained in:
parent
6e4dd2257a
commit
5ec6460efb
@ -4855,6 +4855,12 @@ nsContentUtils::TriggerLink(nsIContent *aContent,
|
||||
fileName.SetIsVoid(true); // No actionable download attribute was found.
|
||||
}
|
||||
|
||||
// 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.get() : EmptyString().get(),
|
||||
fileName, nullptr, nullptr, aIsTrusted);
|
||||
|
@ -2290,6 +2290,12 @@ ConstructJSImplementation(JSContext* aCx, const char* aContractId,
|
||||
{
|
||||
AutoNoJSAPI nojsapi;
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal);
|
||||
if (!window->IsCurrentInnerWindow()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the XPCOM component containing the JS implementation.
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISupports> implISupports = do_CreateInstance(aContractId, &rv);
|
||||
@ -2304,7 +2310,6 @@ ConstructJSImplementation(JSContext* aCx, const char* aContractId,
|
||||
// and our global is a window.
|
||||
nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi =
|
||||
do_QueryInterface(implISupports);
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal);
|
||||
if (gpi) {
|
||||
JS::Rooted<JS::Value> initReturn(aCx);
|
||||
rv = gpi->Init(window, &initReturn);
|
||||
|
@ -397,6 +397,7 @@ NS_IMETHODIMP
|
||||
nsTextInputSelectionImpl::SetCaretReadOnly(bool aReadOnly)
|
||||
{
|
||||
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!mFrameSelection) return NS_ERROR_FAILURE;
|
||||
nsresult result;
|
||||
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShellWeak, &result);
|
||||
if (shell)
|
||||
|
@ -575,6 +575,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;
|
||||
}
|
||||
|
||||
|
@ -509,6 +509,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;
|
||||
}
|
||||
|
||||
|
@ -1288,6 +1288,8 @@ nsExternalAppHandler::nsExternalAppHandler(nsIMIMEInfo * aMIMEInfo,
|
||||
|
||||
// replace platform specific path separator and illegal characters to avoid any confusion
|
||||
mSuggestedFileName.ReplaceChar(KNOWN_PATH_SEPARATORS FILE_ILLEGAL_CHARACTERS, '_');
|
||||
// If null is in an extension, we should assert (see bug 1637745).
|
||||
mSuggestedFileName.ReplaceChar(char16_t(0), '_');
|
||||
mTempFileExtension.ReplaceChar(KNOWN_PATH_SEPARATORS FILE_ILLEGAL_CHARACTERS, '_');
|
||||
|
||||
// Remove unsafe bidi characters which might have spoofing implications (bug 511521).
|
||||
@ -2614,6 +2616,8 @@ NS_IMETHODIMP nsExternalHelperAppService::GetFromTypeAndExtension(const nsACStri
|
||||
NS_PRECONDITION(!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()));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user