mirror of
https://github.com/znc/znc.git
synced 2026-08-08 01:43:03 +02:00
Don't allow @ and . to make their way from username to nick/altnick/ident
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@704 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -11,9 +11,9 @@
|
||||
|
||||
CUser::CUser(const CString& sUserName) {
|
||||
m_uConnectTime = 0;
|
||||
m_sUserName = sUserName;
|
||||
m_sNick = sUserName;
|
||||
m_sIdent = sUserName;
|
||||
SetUserName(sUserName);
|
||||
m_sNick = m_sCleanUserName;
|
||||
m_sIdent = m_sCleanUserName;
|
||||
m_sRealName = sUserName;
|
||||
m_uServerIdx = 0;
|
||||
#ifdef _MODULES
|
||||
@@ -220,9 +220,9 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet) {
|
||||
SetPass(User.GetPass(), User.IsPassHashed());
|
||||
}
|
||||
|
||||
SetNick(User.GetNick());
|
||||
SetAltNick(User.GetAltNick());
|
||||
SetIdent(User.GetIdent());
|
||||
SetNick(User.GetNick(false));
|
||||
SetAltNick(User.GetAltNick(false));
|
||||
SetIdent(User.GetIdent(false));
|
||||
SetRealName(User.GetRealName());
|
||||
SetAwaySuffix(User.GetAwaySuffix());
|
||||
SetStatusPrefix(User.GetStatusPrefix());
|
||||
@@ -405,6 +405,10 @@ bool CUser::IsValidUserName(const CString& sUserName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((*p < 'a' || *p > 'z') && (*p < 'A' || *p > 'Z')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (*p) {
|
||||
if (*p != '@' && *p != '.' && *p != '-' && *p != '_' && !isalnum(*p)) {
|
||||
return false;
|
||||
@@ -907,8 +911,16 @@ CString CUser::GetCurNick() {
|
||||
return "";
|
||||
}
|
||||
|
||||
CString CUser::MakeCleanUserName(const CString& sUserName) {
|
||||
return sUserName.Token(0, false, "@").Replace_n(".", "");
|
||||
}
|
||||
|
||||
// Setters
|
||||
void CUser::SetUserName(const CString& s) { m_sUserName = s; }
|
||||
void CUser::SetUserName(const CString& s) {
|
||||
m_sCleanUserName = CUser::MakeCleanUserName(s);
|
||||
m_sUserName = s;
|
||||
}
|
||||
|
||||
void CUser::SetNick(const CString& s) { m_sNick = s; }
|
||||
void CUser::SetAltNick(const CString& s) { m_sAltNick = s; }
|
||||
void CUser::SetAwaySuffix(const CString& s) { m_sAwaySuffix = s; }
|
||||
@@ -958,11 +970,12 @@ bool CUser::SetStatusPrefix(const CString& s) {
|
||||
|
||||
// Getters
|
||||
const CString& CUser::GetUserName() const { return m_sUserName; }
|
||||
const CString& CUser::GetNick() const { return m_sNick.empty() ? m_sUserName : m_sNick; }
|
||||
const CString& CUser::GetAltNick() const { return m_sAltNick.empty() ? m_sUserName : m_sAltNick; }
|
||||
const CString& CUser::GetAwaySuffix() const { return m_sAwaySuffix; }
|
||||
const CString& CUser::GetIdent() const { return m_sIdent.empty() ? m_sUserName : m_sIdent; }
|
||||
const CString& CUser::GetCleanUserName() const { return m_sCleanUserName; }
|
||||
const CString& CUser::GetNick(bool bAllowDefault) const { return (bAllowDefault && m_sNick.empty()) ? GetCleanUserName() : m_sNick; }
|
||||
const CString& CUser::GetAltNick(bool bAllowDefault) const { return (bAllowDefault && m_sAltNick.empty()) ? GetCleanUserName() : m_sAltNick; }
|
||||
const CString& CUser::GetIdent(bool bAllowDefault) const { return (bAllowDefault && m_sIdent.empty()) ? GetCleanUserName() : m_sIdent; }
|
||||
const CString& CUser::GetRealName() const { return m_sRealName.empty() ? m_sUserName : m_sRealName; }
|
||||
const CString& CUser::GetAwaySuffix() const { return m_sAwaySuffix; }
|
||||
const CString& CUser::GetVHost() const { return m_sVHost; }
|
||||
const CString& CUser::GetPass() const { return m_sPass; }
|
||||
bool CUser::IsPassHashed() const { return m_bPassHashed; }
|
||||
|
||||
@@ -49,6 +49,7 @@ public:
|
||||
bool IsHostAllowed(const CString& sHostMask);
|
||||
bool IsValid(CString& sErrMsg, bool bSkipPass = false) const;
|
||||
static bool IsValidUserName(const CString& sUserName);
|
||||
static CString MakeCleanUserName(const CString& sUserName);
|
||||
bool IsLastServer();
|
||||
bool ConnectPaused();
|
||||
|
||||
@@ -104,9 +105,9 @@ public:
|
||||
void SetUserName(const CString& s);
|
||||
void SetNick(const CString& s);
|
||||
void SetAltNick(const CString& s);
|
||||
void SetAwaySuffix(const CString& s);
|
||||
void SetIdent(const CString& s);
|
||||
void SetRealName(const CString& s);
|
||||
void SetAwaySuffix(const CString& s);
|
||||
void SetVHost(const CString& s);
|
||||
void SetPass(const CString& s, bool bHashed);
|
||||
void SetBounceDCCs(bool b);
|
||||
@@ -132,11 +133,12 @@ public:
|
||||
vector<CClient*>& GetClients() { return m_vClients; }
|
||||
CIRCSock* GetIRCSock();
|
||||
const CString& GetUserName() const;
|
||||
const CString& GetNick() const;
|
||||
const CString& GetAltNick() const;
|
||||
const CString& GetAwaySuffix() const;
|
||||
const CString& GetIdent() const;
|
||||
const CString& GetCleanUserName() const;
|
||||
const CString& GetNick(bool bAllowDefault = true) const;
|
||||
const CString& GetAltNick(bool bAllowDefault = true) const;
|
||||
const CString& GetIdent(bool bAllowDefault = true) const;
|
||||
const CString& GetRealName() const;
|
||||
const CString& GetAwaySuffix() const;
|
||||
const CString& GetVHost() const;
|
||||
const CString& GetPass() const;
|
||||
bool IsPassHashed() const;
|
||||
@@ -171,6 +173,7 @@ private:
|
||||
protected:
|
||||
time_t m_uConnectTime;
|
||||
CString m_sUserName;
|
||||
CString m_sCleanUserName;
|
||||
CString m_sNick;
|
||||
CString m_sAltNick;
|
||||
CString m_sAwaySuffix;
|
||||
|
||||
@@ -524,7 +524,7 @@ bool CZNC::WriteNewConfig(const CString& sConfig) {
|
||||
vsLines.push_back("\tAdmin = false");
|
||||
}
|
||||
|
||||
CUtils::GetInput("Nick", sNick, sUser); vsLines.push_back("\tNick = " + sNick);
|
||||
CUtils::GetInput("Nick", sNick, CUser::MakeCleanUserName(sUser)); vsLines.push_back("\tNick = " + sNick);
|
||||
CUtils::GetInput("Alt Nick", sAnswer, sNick + "_"); if (!sAnswer.empty()) { vsLines.push_back("\tAltNick = " + sAnswer); }
|
||||
CUtils::GetInput("Ident", sAnswer, sNick); vsLines.push_back("\tIdent = " + sAnswer);
|
||||
CUtils::GetInput("Real Name", sAnswer, "Got ZNC?"); vsLines.push_back("\tRealName = " + sAnswer);
|
||||
|
||||
Reference in New Issue
Block a user