mirror of
https://github.com/znc/znc.git
synced 2026-08-06 17:03:14 +02:00
Don't write unexpected newlines to znc.conf
This patch fixes the same bug as the last commit and also makes sure that similar bugs can't happen again. Thanks to cnu for finding and reporting this bug. Thanks to kroimon for patch review. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1396 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -50,16 +50,18 @@ bool CChan::WriteConfig(CFile& File) {
|
||||
return false;
|
||||
}
|
||||
|
||||
File.Write("\t<Chan " + GetName() + ">\n");
|
||||
File.Write("\t<Chan " + GetName().FirstLine() + ">\n");
|
||||
|
||||
if (m_pUser->GetBufferCount() != GetBufferCount())
|
||||
File.Write("\t\tBuffer = " + CString(GetBufferCount()) + "\n");
|
||||
m_pUser->PrintLine(File, "\tBuffer", CString(GetBufferCount()));
|
||||
if (m_pUser->KeepBuffer() != KeepBuffer())
|
||||
File.Write("\t\tKeepBuffer = " + CString(KeepBuffer()) + "\n");
|
||||
m_pUser->PrintLine(File, "\tKeepBuffer", CString(KeepBuffer()));
|
||||
if (IsDetached())
|
||||
File.Write("\t\tDetached = true\n");
|
||||
if (!GetKey().empty()) { File.Write("\t\tKey = " + GetKey() + "\n"); }
|
||||
if (!GetDefaultModes().empty()) { File.Write("\t\tModes = " + GetDefaultModes() + "\n"); }
|
||||
m_pUser->PrintLine(File, "\tDetached", "true");
|
||||
if (!GetKey().empty())
|
||||
m_pUser->PrintLine(File, "\tKey", GetKey());
|
||||
if (!GetDefaultModes().empty())
|
||||
m_pUser->PrintLine(File, "\tModes", GetDefaultModes());
|
||||
|
||||
File.Write("\t</Chan>\n");
|
||||
return true;
|
||||
|
||||
@@ -554,11 +554,12 @@ bool CUser::PrintLine(CFile& File, const CString& sName, const CString& sValue)
|
||||
return false;
|
||||
}
|
||||
|
||||
return File.Write("\t" + sName + " = " + sValue + "\n");
|
||||
return File.Write("\t" + sName.FirstLine()
|
||||
+ " = " + sValue.FirstLine() + "\n");
|
||||
}
|
||||
|
||||
bool CUser::WriteConfig(CFile& File) {
|
||||
File.Write("<User " + GetUserName() + ">\n");
|
||||
File.Write("<User " + GetUserName().FirstLine() + ">\n");
|
||||
|
||||
if (IsPassHashed()) {
|
||||
if (m_sPassSalt.empty()) {
|
||||
|
||||
@@ -104,6 +104,7 @@ public:
|
||||
CString Left(unsigned int uCount) const;
|
||||
CString Right(unsigned int uCount) const;
|
||||
|
||||
CString FirstLine() const { return Token(0, false, "\n"); }
|
||||
CString Token(unsigned int uPos, bool bRest = false, const CString& sSep = " ") const;
|
||||
unsigned int URLSplit(MCString& msRet) const;
|
||||
unsigned int Split(const CString& sDelim, VCString& vsRet, bool bAllowEmpty = true, const CString& sLeft = "", const CString& sRight = "") const;
|
||||
|
||||
@@ -514,7 +514,7 @@ bool CZNC::WriteConfig() {
|
||||
CString sHostPortion = pListener->GetBindHost();
|
||||
|
||||
if (!sHostPortion.empty()) {
|
||||
sHostPortion += " ";
|
||||
sHostPortion = sHostPortion.FirstLine() + " ";
|
||||
}
|
||||
|
||||
CString s6 = (pListener->IsIPV6()) ? "6" : " ";
|
||||
@@ -525,32 +525,39 @@ bool CZNC::WriteConfig() {
|
||||
File.Write("ConnectDelay = " + CString(m_uiConnectDelay) + "\n");
|
||||
|
||||
if (!m_sISpoofFile.empty()) {
|
||||
File.Write("ISpoofFile = " + m_sISpoofFile + "\n");
|
||||
if (!m_sISpoofFormat.empty()) { File.Write("ISpoofFormat = " + m_sISpoofFormat + "\n"); }
|
||||
File.Write("ISpoofFile = " + m_sISpoofFile.FirstLine() + "\n");
|
||||
if (!m_sISpoofFormat.empty()) {
|
||||
File.Write("ISpoofFormat = " + m_sISpoofFormat.FirstLine() + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_sPidFile.empty()) { File.Write("PidFile = " + m_sPidFile + "\n"); }
|
||||
if (!m_sStatusPrefix.empty()) { File.Write("StatusPrefix = " + m_sStatusPrefix + "\n"); }
|
||||
if (!m_sPidFile.empty()) {
|
||||
File.Write("PidFile = " + m_sPidFile.FirstLine() + "\n");
|
||||
}
|
||||
if (!m_sStatusPrefix.empty()) {
|
||||
File.Write("StatusPrefix = " + m_sStatusPrefix.FirstLine() + "\n");
|
||||
}
|
||||
|
||||
for (unsigned int m = 0; m < m_vsMotd.size(); m++) {
|
||||
File.Write("Motd = " + m_vsMotd[m] + "\n");
|
||||
File.Write("Motd = " + m_vsMotd[m].FirstLine() + "\n");
|
||||
}
|
||||
|
||||
for (unsigned int v = 0; v < m_vsVHosts.size(); v++) {
|
||||
File.Write("VHost = " + m_vsVHosts[v] + "\n");
|
||||
File.Write("VHost = " + m_vsVHosts[v].FirstLine() + "\n");
|
||||
}
|
||||
|
||||
#ifdef _MODULES
|
||||
CGlobalModules& Mods = GetModules();
|
||||
|
||||
for (unsigned int a = 0; a < Mods.size(); a++) {
|
||||
CString sName = Mods[a]->GetModName();
|
||||
CString sArgs = Mods[a]->GetArgs();
|
||||
|
||||
if (!sArgs.empty()) {
|
||||
sArgs = " " + sArgs;
|
||||
sArgs = " " + sArgs.FirstLine();
|
||||
}
|
||||
|
||||
File.Write("LoadModule = " + Mods[a]->GetModName() + sArgs + "\n");
|
||||
File.Write("LoadModule = " + sName.FirstLine() + sArgs + "\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user