From c19061cb8d5108edf9274ba6d8a267058dfedf74 Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Wed, 5 Sep 2001 22:24:43 +0000 Subject: [PATCH] fix for #97585. if the user happens to have a directory for their sig file, don't go into an infinite loop. r=ducarroz, sr=bienvenu --- mailnews/base/util/nsMsgI18N.cpp | 8 +++++++- .../compose/resources/locale/en-US/composeMsgs.properties | 4 ++++ mailnews/compose/src/nsMsgCompose.cpp | 7 ++++++- mailnews/compose/src/nsMsgComposeStringBundle.h | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/mailnews/base/util/nsMsgI18N.cpp b/mailnews/base/util/nsMsgI18N.cpp index 196c3e954971..7f3255a8d8b1 100644 --- a/mailnews/base/util/nsMsgI18N.cpp +++ b/mailnews/base/util/nsMsgI18N.cpp @@ -557,10 +557,16 @@ nsMsgI18NParseMetaCharset(nsFileSpec* fileSpec) { static char charset[kMAX_CSNAME+1]; char buffer[512]; - nsInputFileStream fileStream(*fileSpec); *charset = '\0'; + if (fileSpec->IsDirectory()) { + NS_ASSERTION(0,"file is a directory"); + return charset; + } + + nsInputFileStream fileStream(*fileSpec); + while (!fileStream.eof() && !fileStream.failed() && fileStream.is_open()) { fileStream.readline(buffer, 512); diff --git a/mailnews/compose/resources/locale/en-US/composeMsgs.properties b/mailnews/compose/resources/locale/en-US/composeMsgs.properties index 2b041dfe5c8d..233bf122ddbd 100644 --- a/mailnews/compose/resources/locale/en-US/composeMsgs.properties +++ b/mailnews/compose/resources/locale/en-US/composeMsgs.properties @@ -191,6 +191,10 @@ noIdentities=You don't have any email identities yet. Create one with the Accou ## @name NS_MSG_GENERIC_FAILURE_EXPLANATION 12562=Please verify that your Mail/News account settings are correct and try again. +## @name NS_MSG_ERROR_READING_FILE +12563=Error reading file. + + ## @name NS_FOLLOWUPTO_SENDER 12563=The author of this message has requested that responses be sent only to the author. If you also want to reply to the newsgroup, add a new row to the addressing area, choose Newsgroup from the recipients list, and enter the name of the newsgroup. diff --git a/mailnews/compose/src/nsMsgCompose.cpp b/mailnews/compose/src/nsMsgCompose.cpp index cf9da3cbf72b..53bc61bd8f6d 100644 --- a/mailnews/compose/src/nsMsgCompose.cpp +++ b/mailnews/compose/src/nsMsgCompose.cpp @@ -2559,9 +2559,14 @@ nsMsgCompose::LoadDataFromFile(nsFileSpec& fSpec, nsString &sigData) char *readBuf; char *ptr; + if (fSpec.IsDirectory()) { + NS_ASSERTION(0,"file is a directory"); + return NS_MSG_ERROR_READING_FILE; + } + nsInputFileStream tempFile(fSpec); if (!tempFile.is_open()) - return NS_MSG_ERROR_WRITING_FILE; + return NS_MSG_ERROR_READING_FILE; readSize = fSpec.GetFileSize(); ptr = readBuf = (char *)PR_Malloc(readSize + 1); if (!readBuf) diff --git a/mailnews/compose/src/nsMsgComposeStringBundle.h b/mailnews/compose/src/nsMsgComposeStringBundle.h index 1a7b247a40b5..92d7e8a24a75 100644 --- a/mailnews/compose/src/nsMsgComposeStringBundle.h +++ b/mailnews/compose/src/nsMsgComposeStringBundle.h @@ -112,6 +112,7 @@ private: #define NS_ERROR_SEND_FAILED_BUT_NNTP_OK NS_MSG_GENERATE_FAILURE(12560) #define NS_MSG_ASK_TO_COMEBACK_TO_COMPOSE NS_MSG_GENERATE_SUCCESS(12561) #define NS_MSG_GENERIC_FAILURE_EXPLANATION NS_MSG_GENERATE_SUCCESS(12562) +#define NS_MSG_ERROR_READING_FILE NS_MSG_GENERATE_FAILURE(12563) #endif /* _nsMsgComposeStringBundle_H_ */