From ec6964cb2ca1897d40e3abf48cb0243a4af11274 Mon Sep 17 00:00:00 2001 From: psychon Date: Sun, 29 Nov 2009 15:17:39 +0000 Subject: [PATCH] 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 --- znc.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/znc.cpp b/znc.cpp index 21c0ad39..5ecc0a72 100644 --- a/znc.cpp +++ b/znc.cpp @@ -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;