From b58c5aea8393637163ec09d46600b18cf937d5ec Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 3 Jun 2019 22:35:56 +0200 Subject: [PATCH] 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. --- src/common/protocol.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/common/protocol.cpp b/src/common/protocol.cpp index ffe0e0f086..ce6ace14bc 100644 --- a/src/common/protocol.cpp +++ b/src/common/protocol.cpp @@ -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 ) {