ISpoofFormat: Go through ExpandString()

ISpoofFormat now can be used with e.g. %user% which allows some kind of
poor-man's DenySetIdent (force ident to be user name).

For backward compatibility, if ExpandString() doesn't change the string we just
replace all "%" with the user's ident.

Thanks to DarthGandalf for the idea and the patch.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1670 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-11-29 15:17:39 +00:00
parent b0e59f1294
commit ec6964cb2c

View File

@@ -287,7 +287,13 @@ bool CZNC::WriteISpoof(CUser* pUser) {
return false;
}
CString sData = m_sISpoofFormat.Token(0, false, "%") + pUser->GetIdent() + m_sISpoofFormat.Token(1, true, "%");
CString sData = pUser->ExpandString(m_sISpoofFormat);
// If the format doesn't contain anything expandable, we'll
// assume this is an "old"-style format string.
if (sData == m_sISpoofFormat) {
sData.Replace("%", pUser->GetIdent());
}
m_pISpoofLockFile->Write(sData + "\n");
}
return true;