From 8af5fb5da530b5553ba4e8bf23ed87bad7f7a4e9 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 9 Mar 2021 14:38:43 +0100 Subject: [PATCH] [libcalamaresui] Simplify getting URL response - get a QByteArray rather than going through a char[] buffer - bytes-read is not important since the RE can only match if there **are** that many characters. --- src/libcalamaresui/utils/Paste.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libcalamaresui/utils/Paste.cpp b/src/libcalamaresui/utils/Paste.cpp index c84c7bdb4..230199311 100644 --- a/src/libcalamaresui/utils/Paste.cpp +++ b/src/libcalamaresui/utils/Paste.cpp @@ -90,20 +90,17 @@ ficheLogUpload( QObject* parent ) } cDebug() << Logger::SubEntry << "Reading response from paste server"; - - char resp[ 1024 ]; - resp[ 0 ] = '\0'; - qint64 nBytesRead = socket->readLine( resp, 1024 ); + QByteArray responseText = socket->readLine( 1024 ); socket->close(); - QUrl pasteUrl = QUrl( QString( resp ).trimmed(), QUrl::StrictMode ); + QUrl pasteUrl = QUrl( QString( responseText ).trimmed(), QUrl::StrictMode ); QString pasteUrlStr = pasteUrl.toString(); QRegularExpression pasteUrlRegex( "^http[s]?://" + ficheHost ); QString pasteUrlFmt = parent->tr( "Install log posted to\n\n%1\n\nLink copied to clipboard" ); QString pasteUrlMsg = pasteUrlFmt.arg( pasteUrlStr ); - if ( nBytesRead >= 8 && pasteUrl.isValid() && pasteUrlRegex.match( pasteUrlStr ).hasMatch() ) + if ( pasteUrl.isValid() && pasteUrlRegex.match( pasteUrlStr ).hasMatch() ) { QClipboard* clipboard = QApplication::clipboard(); clipboard->setText( pasteUrlStr, QClipboard::Clipboard );