From 924217fd9f9fc4e7dd78bf71f90e3c2fbd046172 Mon Sep 17 00:00:00 2001 From: "Felix (xq) Queißner" Date: Fri, 19 Jun 2020 00:52:34 +0200 Subject: Adds safety measure to prevent Kristall send too large input messages to the server. --- src/browsertab.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'src/browsertab.cpp') diff --git a/src/browsertab.cpp b/src/browsertab.cpp index 1738483..cd1ec4f 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -467,7 +467,7 @@ File Size: %2 QString title = this->current_location.toString(); emit this->titleChanged(title); - emit this->fileLoaded(data.size(), mime_text, this->timer.elapsed()); + emit this->fileLoaded(ref_data.size(), mime_text, this->timer.elapsed()); this->successfully_loaded = true; @@ -481,15 +481,29 @@ void BrowserTab::on_inputRequired(const QString &query) dialog.setInputMode(QInputDialog::TextInput); dialog.setLabelText(query); - if (dialog.exec() != QDialog::Accepted) + while(true) { - setErrorMessage(QString("Site requires input:\n%1").arg(query)); - return; - } + if (dialog.exec() != QDialog::Accepted) + { + setErrorMessage(QString("Site requires input:\n%1").arg(query)); + return; + } + + QUrl new_location = current_location; + new_location.setQuery(dialog.textValue()); - QUrl new_location = current_location; - new_location.setQuery(dialog.textValue()); - this->navigateTo(new_location, DontPush); + int len = new_location.toString(QUrl::FullyEncoded).toUtf8().size(); + if(len >= 1020) { + QMessageBox::warning( + this, + "Kristall", + tr("Your input message is too long. Your input is %1 bytes, but a maximum of %2 bytes are allowed.\r\nPlease cancel or shorten your input.").arg(len).arg(1020) + ); + } else { + this->navigateTo(new_location, DontPush); + break; + } + } } void BrowserTab::on_redirected(const QUrl &uri, bool is_permanent) -- cgit v1.2.3