Commit 35ff3a72 authored by Yaroslav Sidlovsky's avatar Yaroslav Sidlovsky 💬 Committed by Kurt Hindenburg

Use Qurl::fromPercentEncoding for bookmarks

This will allow % in URLs; also sync test code with actual code.
Previously the tests were using toUtf8(); however fromPercentEncoding
seems better.

BUG: 420791
Differential Revision: https://phabricator.kde.org/D29322

(cherry picked from commit d3519ae2)
parent e1fbdcb6
......@@ -335,7 +335,8 @@ void SessionController::openUrl(const QUrl& url)
} else if (url.scheme().isEmpty()) {
// QUrl couldn't parse what the user entered into the URL field
// so just dump it to the shell
QString command = url.toDisplayString();
// If you change this, change it also in autotests/BookMarkTest.cpp
QString command = QUrl::fromPercentEncoding(url.toEncoded());
if (!command.isEmpty()) {
_session->sendTextToTerminal(command, QLatin1Char('\r'));
}
......
......@@ -45,16 +45,16 @@ void BookMarkTest::testBookMarkURLs_data()
QStringLiteral("command with pipe (|)"), QStringLiteral("ssh machine | tee -a /var/log/system.log"),
QStringLiteral("file URL w/ non ASCII part"), QStringLiteral("file:///home/user/aκόσμε"),
QStringLiteral("command with double quotes"), QStringLiteral("isql-fb -u sysdba -p example \"test\""),
QStringLiteral("command with single quotes"), QStringLiteral("isql-fb -u sysdba -p example 'test'")
QStringLiteral("command with single quotes"), QStringLiteral("isql-fb -u sysdba -p example 'test'"),
QStringLiteral("command with %"), QStringLiteral("date +%m-%d-%Y")
};
QTest::addColumn<QString>("text");
QTest::addColumn<QString>("result");
for (int i = 0; i < groupUrlList.size(); ++i) {
const auto& bm_url = groupUrlList.at(i);
// Current Konsole code using bm.url()
// The below is new to test decoding the url/command
auto bm = QUrl::fromPercentEncoding(bm_url.url().toUtf8());
// Verify this line matching SessionControll.cpp to validate tests
auto bm = QUrl::fromPercentEncoding(bm_url.toEncoded());
QTest::newRow(bm_urls.at(i * 2).toUtf8().data())<< bm_urls.at((i * 2) +1) << bm;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment