fix bug #22450. if the user has an @ in there pop username, truncate at that point

when sending the username to the server.  (but the full thing will show up in the ui and in
the password dialog)

now we support the "mail.allow_at_sign_in_user_name" pref.

bring over the comments from the 4.x code base.

this fix will also fix pop for users who entered there full email address as there pop username
This commit is contained in:
sspitzer%netscape.com 1999-12-29 20:50:27 +00:00
Родитель 0f984615d6
Коммит 04b7228154
2 изменённых файлов: 38 добавлений и 4 удалений

Просмотреть файл

@ -40,11 +40,14 @@
#include "nsLocalStringBundle.h"
#include "nsTextFormater.h"
#include "nsCOMPtr.h"
#include "nsIPref.h"
#define PREF_MAIL_ALLOW_AT_SIGN_IN_USER_NAME "mail.allow_at_sign_in_user_name"
static PRLogModuleInfo *POP3LOGMODULE = nsnull;
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
/* km
*
@ -377,7 +380,8 @@ nsPop3Protocol::nsPop3Protocol(nsIURI* aURL)
m_totalDownloadSize(0),
m_totalBytesReceived(0),
m_lineStreamBuffer(nsnull),
m_pop3ConData(nsnull)
m_pop3ConData(nsnull),
m_allow_at_sign_in_mail_user_name(PR_FALSE)
{
SetLookingForCRLF(MSG_LINEBREAK_LEN == 2);
}
@ -425,6 +429,18 @@ nsresult nsPop3Protocol::Initialize(nsIURI * aURL)
if(!m_lineStreamBuffer)
return NS_ERROR_OUT_OF_MEMORY;
NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
/* the old comment in mkpop3.c in the old source tree:
*
* Well, someone finally found a legitimate reason to put an @ in the
* mail server user name. They're trying to use the user name as a UID
* in the LDAP directory, and the UIDs happen to have the format
* foo@bar.com. We don't change our default behavior, but we let admins
* turn it off if they want
*/
rv = prefs->GetBoolPref(PREF_MAIL_ALLOW_AT_SIGN_IN_USER_NAME, &m_allow_at_sign_in_mail_user_name);
return rv;
}
@ -467,9 +483,26 @@ void nsPop3Protocol::UpdateProgressPercent (PRUint32 totalDone, PRUint32 total)
void nsPop3Protocol::SetUsername(const char* name)
{
NS_ASSERTION(name, "no name specified!");
if (name)
NS_ASSERTION(name, "no name specified!");
if (name) {
m_username = name;
/*
* If we are called with data like "fred@bedrock.com", then we will
* help the user by ignoring the stuff after the "@". People with
* @ signs in their user names will be hosed. They also can't possibly
* be current happy internet users. This will waste a few bytes,
* but was the minimal change to make in order to ship cheddar.
* (it might even save bytes by avoiding the code which does the
* right thing)
*/
if (!m_allow_at_sign_in_mail_user_name) {
PRInt32 atPos = -1;
atPos = m_username.FindChar('@');
if (atPos != -1) {
m_username.Truncate(atPos);
}
}
}
}
nsresult nsPop3Protocol::GetPassword(char ** aPassword)

Просмотреть файл

@ -288,6 +288,7 @@ private:
nsMsgLineStreamBuffer * m_lineStreamBuffer; // used to efficiently extract lines from the incoming data stream
Pop3ConData* m_pop3ConData;
PRBool m_allow_at_sign_in_mail_user_name;
void FreeMsgInfo();
//////////////////////////////////////////////////////////////////////////////////////////