mirror of
https://github.com/znc/znc.git
synced 2026-05-08 06:14:40 +02:00
Add test for #1229 and actually fix it.
This commit is contained in:
@@ -45,10 +45,8 @@ class CZNCSock : public Csock {
|
||||
m_ssTrustedFingerprints = ssFPs;
|
||||
}
|
||||
|
||||
#ifndef HAVE_ICU
|
||||
// Don't fail to compile when ICU is not enabled
|
||||
void SetEncoding(const CString&) {}
|
||||
#endif
|
||||
void SetEncoding(const CString&);
|
||||
|
||||
virtual CString GetRemoteIP() const { return Csock::GetRemoteIP(); }
|
||||
|
||||
protected:
|
||||
|
||||
+1
-1
@@ -384,7 +384,7 @@ void CClient::AcceptLogin(CUser& User) {
|
||||
SetTimeout(CIRCNetwork::NO_TRAFFIC_TIMEOUT, TMO_READ);
|
||||
|
||||
SetSockName("USR::" + m_pUser->GetUserName());
|
||||
SetEncoding(CZNC::Get().FixupEncoding(m_pUser->GetClientEncoding()));
|
||||
SetEncoding(m_pUser->GetClientEncoding());
|
||||
|
||||
if (!m_sNetwork.empty()) {
|
||||
m_pNetwork = m_pUser->FindNetwork(m_sNetwork);
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ CIRCSock::CIRCSock(CIRCNetwork* pNetwork)
|
||||
EnableReadLine();
|
||||
m_Nick.SetIdent(m_pNetwork->GetIdent());
|
||||
m_Nick.SetHost(m_pNetwork->GetBindHost());
|
||||
SetEncoding(CZNC::Get().FixupEncoding((m_pNetwork->GetEncoding())));
|
||||
SetEncoding(m_pNetwork->GetEncoding());
|
||||
|
||||
m_mueChanModes['b'] = ListArg;
|
||||
m_mueChanModes['e'] = ListArg;
|
||||
|
||||
@@ -176,6 +176,12 @@ CString CZNCSock::GetSSLPeerFingerprint() const {
|
||||
#endif
|
||||
}
|
||||
|
||||
void CZNCSock::SetEncoding(const CString& sEncoding) {
|
||||
#ifdef HAVE_ICU
|
||||
Csock::SetEncoding(CZNC::Get().FixupEncoding(sEncoding));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
class CSockManager::CThreadMonitorFD : public CSMonitorFD {
|
||||
public:
|
||||
|
||||
+8
-1
@@ -2072,7 +2072,14 @@ void CZNC::ResumeConnectQueue() {
|
||||
}
|
||||
}
|
||||
|
||||
void CZNC::ForceEncoding() { m_uiForceEncoding++; }
|
||||
void CZNC::ForceEncoding() {
|
||||
m_uiForceEncoding++;
|
||||
for (Csock* pSock : GetManager()) {
|
||||
if (pSock->GetEncoding().empty()) {
|
||||
pSock->SetEncoding("UTF-8");
|
||||
}
|
||||
}
|
||||
}
|
||||
void CZNC::UnforceEncoding() { m_uiForceEncoding--; }
|
||||
bool CZNC::IsForcingEncoding() const { return m_uiForceEncoding; }
|
||||
CString CZNC::FixupEncoding(const CString& sEncoding) const {
|
||||
|
||||
+12
-7
@@ -76,7 +76,7 @@ class IO {
|
||||
m_readed += chunk;
|
||||
}
|
||||
}
|
||||
void Write(QString s = "", bool new_line = true) {
|
||||
void Write(QByteArray s = "", bool new_line = true) {
|
||||
if (!m_device) return;
|
||||
if (m_verbose) {
|
||||
std::cout << s.toStdString() << std::flush;
|
||||
@@ -85,9 +85,10 @@ class IO {
|
||||
}
|
||||
}
|
||||
s += "\n";
|
||||
{
|
||||
QTextStream str(m_device);
|
||||
str << s;
|
||||
while (!s.isEmpty()) {
|
||||
auto res = m_device->write(s);
|
||||
ASSERT_NE(res, -1);
|
||||
s.remove(0, res);
|
||||
}
|
||||
FlushIfCan(m_device);
|
||||
}
|
||||
@@ -103,8 +104,7 @@ class IO {
|
||||
}
|
||||
|
||||
private:
|
||||
// QTextStream doesn't flush QTcpSocket, and QIODevice doesn't have flush()
|
||||
// at all...
|
||||
// Need to flush QTcpSocket, and QIODevice doesn't have flush at all...
|
||||
static void FlushIfCan(QIODevice*) {}
|
||||
static void FlushIfCan(QTcpSocket* sock) { sock->flush(); }
|
||||
|
||||
@@ -469,7 +469,7 @@ TEST_F(ZNCTest, ControlpanelModule) {
|
||||
auto client = LoginClient();
|
||||
Z;
|
||||
|
||||
const QString request = "PRIVMSG *controlpanel :";
|
||||
const QByteArray request = "PRIVMSG *controlpanel :";
|
||||
const QByteArray response = ":*controlpanel!znc@znc.in PRIVMSG nick :";
|
||||
|
||||
// TODO: Figure out how to check for "HAVE_ICU" to test encoding.
|
||||
@@ -1766,6 +1766,11 @@ TEST_F(ZNCTest, Modpython) {
|
||||
client.Write("PRIVMSG *pyeval :module.GetUser().GetUserName()");
|
||||
client.ReadUntil("nick :'user'");
|
||||
Z;
|
||||
ircd.Write(":server 001 nick :Hello");
|
||||
ircd.Write(":n!u@h PRIVMSG nick :Hi\xF0, github issue #1229");
|
||||
// "replacement character"
|
||||
client.ReadUntil("Hi\xEF\xBF\xBD, github issue");
|
||||
Z;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Vendored
+1
-1
Submodule third_party/Csocket updated: 2852fc3645...24ea8547f5
Reference in New Issue
Block a user