Skip to content

Commit

Permalink
Handle url rediredcts with changed trailing slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOneRing committed Dec 1, 2020
1 parent 5721b6d commit 94e8903
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
29 changes: 21 additions & 8 deletions src/gui/accountstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,33 @@ Q_LOGGING_CATEGORY(lcAccountState, "gui.account.state", QtInfoMsg)

void AccountState::updateUrlDialog(AccountPtr account, const QUrl &newUrl, std::function<void()> callback)
{
auto diag = new QMessageBox(QMessageBox::Warning, tr("Url update requested for %1").arg(account->displayName()),
tr("The url for %1 changed from %2 to %3, do you want to accept the changed url").arg(account->displayName(), account->url().toString(), newUrl.toString()),
QMessageBox::NoButton, ocApp()->gui()->settingsDialog());
diag->setAttribute(Qt::WA_DeleteOnClose);
auto yes = diag->addButton(tr("Change url permanently to %1").arg(newUrl.toString()), QMessageBox::AcceptRole);
diag->addButton(tr("Reject"), QMessageBox::RejectRole);
QObject::connect(diag, &QMessageBox::finished, account.data(), [diag, yes, newUrl, account, callback] {
if (diag->clickedButton() == yes) {
auto accept = [=](bool accepted) {
if (accepted) {
account->setUrl(newUrl);
Q_EMIT account->wantsAccountSaved(account.data());
}
if (callback) {
callback();
}
};
// the urls are identical, previous versions of owncloud cropped the /
if (newUrl.path() == QLatin1Char('/')) {
auto tmp = newUrl;
tmp.setPath(QString());
if (tmp == account->url()) {
// silently accept the /
accept(true);
return;
}
}
auto diag = new QMessageBox(QMessageBox::Warning, tr("Url update requested for %1").arg(account->displayName()),
tr("The url for %1 changed from %2 to %3, do you want to accept the changed url").arg(account->displayName(), account->url().toString(), newUrl.toString()),
QMessageBox::NoButton, ocApp()->gui()->settingsDialog());
diag->setAttribute(Qt::WA_DeleteOnClose);
auto yes = diag->addButton(tr("Change url permanently to %1").arg(newUrl.toString()), QMessageBox::AcceptRole);
diag->addButton(tr("Reject"), QMessageBox::RejectRole);
QObject::connect(diag, &QMessageBox::finished, account.data(), [diag, yes, accept] {
accept(diag->clickedButton() == yes);
});
diag->show();
}
Expand Down
6 changes: 1 addition & 5 deletions src/libsync/networkjobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,7 @@ void CheckServerJob::metaDataChangedSlot()

bool CheckServerJob::finished()
{
const QUrl targetUrl = [this] {
QUrl redirectUrl = reply()->url();
redirectUrl.setPath(redirectUrl.path().remove(QStringLiteral("/status.php")));
return redirectUrl;
}();
const QUrl targetUrl = reply()->url().adjusted(QUrl::RemoveFilename);
if (targetUrl.scheme() == QLatin1String("https")
&& reply()->sslConfiguration().sessionTicket().isEmpty()
&& reply()->error() == QNetworkReply::NoError) {
Expand Down

0 comments on commit 94e8903

Please sign in to comment.