зеркало из https://github.com/mozilla/pjs.git
bug 417780 prevent tmpfile creation failures due to illegal chars in suggested name, r/sr=bsmedberg,neil
This commit is contained in:
Родитель
90f91d1868
Коммит
6ecac69e59
|
@ -1215,6 +1215,7 @@ nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel * aChannel)
|
|||
nsCAutoString ext;
|
||||
mMimeInfo->GetPrimaryExtension(ext);
|
||||
if (!ext.IsEmpty()) {
|
||||
ext.ReplaceChar(FILE_PATH_SEPARATOR FILE_ILLEGAL_CHARACTERS, '_');
|
||||
if (ext.First() != '.')
|
||||
tempLeafName.Append('.');
|
||||
tempLeafName.Append(ext);
|
||||
|
@ -1229,8 +1230,10 @@ nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel * aChannel)
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Set the file name without .part
|
||||
dummyFile->Append(NS_ConvertUTF8toUTF16(tempLeafName));
|
||||
dummyFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
|
||||
rv = dummyFile->Append(NS_ConvertUTF8toUTF16(tempLeafName));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = dummyFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Store executable-ness then delete
|
||||
dummyFile->IsExecutable(&mTempFileIsExecutable);
|
||||
|
@ -1241,9 +1244,11 @@ nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel * aChannel)
|
|||
// default application.
|
||||
tempLeafName.Append(NS_LITERAL_CSTRING(".part"));
|
||||
|
||||
mTempFile->Append(NS_ConvertUTF8toUTF16(tempLeafName));
|
||||
rv = mTempFile->Append(NS_ConvertUTF8toUTF16(tempLeafName));
|
||||
// make this file unique!!!
|
||||
mTempFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = mTempFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
#ifndef XP_WIN
|
||||
// On other platforms, the file permission bits are used, so we can just call
|
||||
|
|
Загрузка…
Ссылка в новой задаче