From 9b93c4d7c5a450607eca0174b1899e56d6a09a48 Mon Sep 17 00:00:00 2001 From: "Felix (xq) Queißner" Date: Wed, 10 Jun 2020 01:24:39 +0200 Subject: Improves gophermaps: Now handle '+' correctly, improves gopher protocol such that it now respects *the lone dot*. --- src/gopherclient.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/gopherclient.cpp') diff --git a/src/gopherclient.cpp b/src/gopherclient.cpp index 17faceb..2c2cdf5 100644 --- a/src/gopherclient.cpp +++ b/src/gopherclient.cpp @@ -34,7 +34,7 @@ bool GopherClient::startRequest(const QUrl &url) else if(type == "h") mime = "text/html"; else if(type == "s") mime = "audio/unknown"; - qDebug() << url << "→" << mime; + is_processing_binary = (type == "5") or (type == "9") or (type == "I") or (type == "g"); this->requested_url = url; this->was_cancelled = false; @@ -66,6 +66,15 @@ void GopherClient::on_connected() void GopherClient::on_readRead() { body.append(socket.readAll()); + + if(not is_processing_binary) { + // Strip the "lone dot" from gopher data + if(int index = body.indexOf(".\r\n"); index >= 0) { + body.resize(index); + socket.close(); + } + } + emit this->requestProgress(body.size()); } @@ -74,7 +83,6 @@ void GopherClient::on_finished() if(not was_cancelled) { emit this->requestComplete(this->body, mime); - was_cancelled = true; } body.clear(); -- cgit v1.2.3