aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTobias Fella <fella@posteo.de>2021-09-10 22:10:16 +0200
committerTobias Fella <fella@posteo.de>2021-09-10 22:10:16 +0200
commit4106a073d03b4ba9176da24c6b169c5fc2c79fb4 (patch)
tree73fa6384239601b2bb639fed3e6e11cf00907c86 /lib
parent8dfa505066a03cc8450527699634fda71cbd8915 (diff)
downloadlibquotient-4106a073d03b4ba9176da24c6b169c5fc2c79fb4.tar.gz
libquotient-4106a073d03b4ba9176da24c6b169c5fc2c79fb4.zip
Percent-encode all the things
Diffstat (limited to 'lib')
-rw-r--r--lib/networkaccessmanager.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/networkaccessmanager.cpp b/lib/networkaccessmanager.cpp
index f37e26b6..dc1c139c 100644
--- a/lib/networkaccessmanager.cpp
+++ b/lib/networkaccessmanager.cpp
@@ -70,7 +70,7 @@ QNetworkReply* NetworkAccessManager::createRequest(
const auto fragmentParts = fragment.split(QLatin1Char('/'));
const auto mediaId = request.url().toString(QUrl::RemoveScheme | QUrl::RemoveFragment);
if (fragmentParts.size() == 3) {
- auto connection = AccountRegistry::instance().get(fragmentParts[0]);
+ auto connection = AccountRegistry::instance().get(QUrl::fromPercentEncoding(fragmentParts[0].toLatin1()));
if(!connection) {
qWarning() << "Connection not found";
return new MxcReply();
@@ -83,7 +83,7 @@ QNetworkReply* NetworkAccessManager::createRequest(
QNetworkRequest r(request);
r.setUrl(QUrl(QStringLiteral("%1/_matrix/media/r0/download/%2").arg(connection->homeserver().toString(), mediaId)));
auto reply = createRequest(QNetworkAccessManager::GetOperation, r);
- return new MxcReply(reply, room, fragmentParts[2]);
+ return new MxcReply(reply, room, QUrl::fromPercentEncoding(fragmentParts[2].toLatin1()));
} else if(fragmentParts.size() == 1) {
auto connection = AccountRegistry::instance().get(fragment);
if(!connection) {
@@ -113,10 +113,10 @@ QStringList NetworkAccessManager::supportedSchemesImplementation() const
QUrl NetworkAccessManager::urlForRoomEvent(Room *room, const QString &eventId, const QString &mediaId)
{
- return QUrl(QStringLiteral("mxc:%1#%2/%3/%4").arg(mediaId, room->connection()->userId(), room->id(), eventId));
+ return QUrl(QStringLiteral("mxc:%1#%2/%3/%4").arg(mediaId, QString(QUrl::toPercentEncoding(room->connection()->userId())), room->id(), QString(QUrl::toPercentEncoding(eventId))));
}
QUrl NetworkAccessManager::urlForFile(Connection *connection, const QString &mediaId)
{
- return QUrl(QStringLiteral("mxc:%1#%2").arg(mediaId, connection->userId()));
+ return QUrl(QStringLiteral("mxc:%1#%2").arg(mediaId, QString(QUrl::toPercentEncoding(connection->userId()))));
} \ No newline at end of file