diff --git a/mozilla/mailnews/local/src/nsPop3Protocol.cpp b/mozilla/mailnews/local/src/nsPop3Protocol.cpp index bf574451d61..54c5afb6c00 100644 --- a/mozilla/mailnews/local/src/nsPop3Protocol.cpp +++ b/mozilla/mailnews/local/src/nsPop3Protocol.cpp @@ -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) diff --git a/mozilla/mailnews/local/src/nsPop3Protocol.h b/mozilla/mailnews/local/src/nsPop3Protocol.h index 4595e101a97..3da183c2fae 100644 --- a/mozilla/mailnews/local/src/nsPop3Protocol.h +++ b/mozilla/mailnews/local/src/nsPop3Protocol.h @@ -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(); //////////////////////////////////////////////////////////////////////////////////////////