mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Ensure commands executed via FIFO are valid UTF-8
This commit is contained in:
parent
b6689bc012
commit
3656c95eca
|
@ -9,7 +9,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
void CFifo::Init(IConsole *pConsole, char *pFifoFile, int Flag)
|
void CFifo::Init(IConsole *pConsole, const char *pFifoFile, int Flag)
|
||||||
{
|
{
|
||||||
m_File = -1;
|
m_File = -1;
|
||||||
|
|
||||||
|
@ -70,18 +70,23 @@ void CFifo::Update()
|
||||||
if(aBuf[i] != '\n')
|
if(aBuf[i] != '\n')
|
||||||
continue;
|
continue;
|
||||||
aBuf[i] = '\0';
|
aBuf[i] = '\0';
|
||||||
|
if(str_utf8_check(pCur))
|
||||||
|
{
|
||||||
m_pConsole->ExecuteLineFlag(pCur, m_Flag, -1);
|
m_pConsole->ExecuteLineFlag(pCur, m_Flag, -1);
|
||||||
|
}
|
||||||
pCur = aBuf + i + 1;
|
pCur = aBuf + i + 1;
|
||||||
}
|
}
|
||||||
if(pCur < aBuf + Length) // missed the last line
|
if(pCur < aBuf + Length && str_utf8_check(pCur)) // missed the last line
|
||||||
|
{
|
||||||
m_pConsole->ExecuteLineFlag(pCur, m_Flag, -1);
|
m_pConsole->ExecuteLineFlag(pCur, m_Flag, -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(CONF_FAMILY_WINDOWS)
|
#elif defined(CONF_FAMILY_WINDOWS)
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
void CFifo::Init(IConsole *pConsole, char *pFifoFile, int Flag)
|
void CFifo::Init(IConsole *pConsole, const char *pFifoFile, int Flag)
|
||||||
{
|
{
|
||||||
m_pConsole = pConsole;
|
m_pConsole = pConsole;
|
||||||
if(pFifoFile[0] == '\0')
|
if(pFifoFile[0] == '\0')
|
||||||
|
@ -187,11 +192,16 @@ void CFifo::Update()
|
||||||
if(pBuf[i] != '\n')
|
if(pBuf[i] != '\n')
|
||||||
continue;
|
continue;
|
||||||
pBuf[i] = '\0';
|
pBuf[i] = '\0';
|
||||||
|
if(str_utf8_check(pCur))
|
||||||
|
{
|
||||||
m_pConsole->ExecuteLineFlag(pCur, m_Flag, -1);
|
m_pConsole->ExecuteLineFlag(pCur, m_Flag, -1);
|
||||||
|
}
|
||||||
pCur = pBuf + i + 1;
|
pCur = pBuf + i + 1;
|
||||||
}
|
}
|
||||||
if(pCur < pBuf + Length) // missed the last line
|
if(pCur < pBuf + Length && str_utf8_check(pCur)) // missed the last line
|
||||||
|
{
|
||||||
m_pConsole->ExecuteLineFlag(pCur, m_Flag, -1);
|
m_pConsole->ExecuteLineFlag(pCur, m_Flag, -1);
|
||||||
|
}
|
||||||
|
|
||||||
free(pBuf);
|
free(pBuf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ class CFifo
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void Init(IConsole *pConsole, char *pFifoFile, int Flag);
|
void Init(IConsole *pConsole, const char *pFifoFile, int Flag);
|
||||||
void Update();
|
void Update();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue