diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-19 00:52:34 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-19 00:52:34 +0200 |
| commit | 924217fd9f9fc4e7dd78bf71f90e3c2fbd046172 (patch) | |
| tree | 7842378cfa83c339d96899c6c0e6c7369c9be08b /src/browsertab.cpp | |
| parent | dd7090dda0370f35e0e0e2e17f3120d906aa2080 (diff) | |
| download | kristall-924217fd9f9fc4e7dd78bf71f90e3c2fbd046172.tar.gz | |
Adds safety measure to prevent Kristall send too large input messages to the server.
Diffstat (limited to 'src/browsertab.cpp')
| -rw-r--r-- | src/browsertab.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
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) |
