diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2021-10-04 18:39:21 +0200 |
---|---|---|
committer | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2021-10-04 18:39:55 +0200 |
commit | 96f31d7d8ed1c9ab905c24ac039079aea622f4dc (patch) | |
tree | 06fea86951340d25a02cdd6f7eb89164be814bd9 /lib/jobs/syncjob.cpp | |
parent | 7c11f7fddbcc98e4b3b92060c475799d7518624c (diff) | |
download | libquotient-96f31d7d8ed1c9ab905c24ac039079aea622f4dc.tar.gz libquotient-96f31d7d8ed1c9ab905c24ac039079aea622f4dc.zip |
BaseJob: percent-encode variable path parts
This is meant to spare clients from having to percent-encode
room aliases, v3 event ids etc. that happen to hit the endpoint path.
It is unfair to expect clients to do that since they are not supposed
to care about the shape of CS API, which parameter should be encoded
in which way. The trick (together with the slightly updated GTAD
configuration) is to percent-encode parts that happen to be QStrings
and not `const char[]`'s while passing all constant parts as plain
C character literals. This also allows to make it more certain that
the path is correctly encoded by passing and storing QByteArray's
wherever the path is already encoded, and only use QStrings (next to
const char arrays) before that.
Since the change alters the API contract (even if that contract was
crappy), some crude detection of percent-encoded stuff on input is
inserted; if input is already percent-encoded, a warning is put to
the logs, alerting developers about the change.
Diffstat (limited to 'lib/jobs/syncjob.cpp')
-rw-r--r-- | lib/jobs/syncjob.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/jobs/syncjob.cpp b/lib/jobs/syncjob.cpp index 59a34ef3..9b1b46f0 100644 --- a/lib/jobs/syncjob.cpp +++ b/lib/jobs/syncjob.cpp @@ -10,7 +10,7 @@ static size_t jobId = 0; SyncJob::SyncJob(const QString& since, const QString& filter, int timeout, const QString& presence) : BaseJob(HttpVerb::Get, QStringLiteral("SyncJob-%1").arg(++jobId), - QStringLiteral("_matrix/client/r0/sync")) + "_matrix/client/r0/sync") { setLoggingCategory(SYNCJOB); QUrlQuery query; |