Try to accept 8-bit data in wxProtocol::ReadLine() too

Even though the data is supposed to be 7-bit here, we can make an effort
to decode 8-bit data if we get any as it can't be worse than just
throwing it away.

Closes https://github.com/wxWidgets/wxWidgets/pull/1336

Closes #2793.
This commit is contained in:
Vadim Zeitlin
2019-06-03 22:35:56 +02:00
parent a4f2303361
commit b58c5aea83

View File

@@ -117,6 +117,11 @@ wxProtocolError wxProtocol::ReadLine(wxSocketBase *sock, wxString& result)
result.clear();
// Although we're supposed to get 7-bit ASCII from the server, some FTP
// servers are known to send 8-bit data, so we try to decode it in
// any way that works as this is more useful than just throwing it away.
wxWhateverWorksConv conv;
wxCharBuffer buf(LINE_BUF);
char *pBuf = buf.data();
while ( sock->WaitForRead() )
@@ -168,7 +173,7 @@ wxProtocolError wxProtocol::ReadLine(wxSocketBase *sock, wxString& result)
return wxPROTO_NETERR;
pBuf[nRead] = '\0';
result += wxString::FromAscii(pBuf);
result += conv.cMB2WX(pBuf);
if ( eol )
{