Skip to content
Snippets Groups Projects
Verified Commit 2de35c1b authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Cleanup for push rules escaping

parent 5d2f055e
No related branches found
No related tags found
No related merge requests found
Pipeline #1094 passed
...@@ -576,10 +576,12 @@ Client::get_pushrules(const std::string &scope, ...@@ -576,10 +576,12 @@ Client::get_pushrules(const std::string &scope,
const std::string &ruleId, const std::string &ruleId,
Callback<mtx::pushrules::PushRule> cb) Callback<mtx::pushrules::PushRule> cb)
{ {
get<mtx::pushrules::PushRule>("/client/r0/pushrules/" + scope + "/" + kind + "/" + ruleId, get<mtx::pushrules::PushRule>(
[cb](const mtx::pushrules::PushRule &res, "/client/r0/pushrules/" + mtx::client::utils::url_encode(scope) + "/" +
HeaderFields, mtx::client::utils::url_encode(kind) + "/" + mtx::client::utils::url_encode(ruleId),
RequestErr err) { cb(res, err); }); [cb](const mtx::pushrules::PushRule &res, HeaderFields, RequestErr err) {
cb(res, err);
});
} }
void void
...@@ -588,7 +590,8 @@ Client::delete_pushrules(const std::string &scope, ...@@ -588,7 +590,8 @@ Client::delete_pushrules(const std::string &scope,
const std::string &ruleId, const std::string &ruleId,
ErrCallback cb) ErrCallback cb)
{ {
delete_("/client/r0/pushrules/" + scope + "/" + kind + "/" + delete_("/client/r0/pushrules/" + mtx::client::utils::url_encode(scope) + "/" +
mtx::client::utils::url_encode(kind) + "/" +
mtx::client::utils::url_encode(ruleId), mtx::client::utils::url_encode(ruleId),
cb); cb);
} }
...@@ -610,11 +613,12 @@ Client::put_pushrules(const std::string &scope, ...@@ -610,11 +613,12 @@ Client::put_pushrules(const std::string &scope,
if (!after.empty()) if (!after.empty())
params.emplace("after", after); params.emplace("after", after);
put<mtx::pushrules::PushRule>("/client/r0/pushrules/" + scope + "/" + kind + "/" + std::string path = "/client/r0/pushrules/" + mtx::client::utils::url_encode(scope) + "/" +
mtx::client::utils::url_encode(ruleId) + "?" + mtx::client::utils::url_encode(kind) + "/" +
mtx::client::utils::query_params(params), mtx::client::utils::url_encode(ruleId);
rule, if (!params.empty())
cb); path += "?" + mtx::client::utils::query_params(params);
put<mtx::pushrules::PushRule>(path, rule, cb);
} }
void void
...@@ -624,8 +628,9 @@ Client::get_pushrules_enabled(const std::string &scope, ...@@ -624,8 +628,9 @@ Client::get_pushrules_enabled(const std::string &scope,
Callback<mtx::pushrules::Enabled> cb) Callback<mtx::pushrules::Enabled> cb)
{ {
get<mtx::pushrules::Enabled>( get<mtx::pushrules::Enabled>(
"/client/r0/pushrules/" + scope + "/" + kind + "/" + "/client/r0/pushrules/" + mtx::client::utils::url_encode(scope) + "/" +
mtx::client::utils::url_encode(ruleId) + "/enabled", mtx::client::utils::url_encode(kind) + "/" + mtx::client::utils::url_encode(ruleId) +
"/enabled",
[cb](const mtx::pushrules::Enabled &res, HeaderFields, RequestErr err) { cb(res, err); }); [cb](const mtx::pushrules::Enabled &res, HeaderFields, RequestErr err) { cb(res, err); });
} }
...@@ -636,7 +641,9 @@ Client::put_pushrules_enabled(const std::string &scope, ...@@ -636,7 +641,9 @@ Client::put_pushrules_enabled(const std::string &scope,
bool enabled, bool enabled,
ErrCallback cb) ErrCallback cb)
{ {
put<mtx::pushrules::Enabled>("/client/r0/pushrules/" + scope + "/" + kind + "/" + put<mtx::pushrules::Enabled>("/client/r0/pushrules/" +
mtx::client::utils::url_encode(scope) + "/" +
mtx::client::utils::url_encode(kind) + "/" +
mtx::client::utils::url_encode(ruleId) + "/enabled", mtx::client::utils::url_encode(ruleId) + "/enabled",
{enabled}, {enabled},
cb); cb);
...@@ -648,11 +655,13 @@ Client::get_pushrules_actions(const std::string &scope, ...@@ -648,11 +655,13 @@ Client::get_pushrules_actions(const std::string &scope,
const std::string &ruleId, const std::string &ruleId,
Callback<mtx::pushrules::actions::Actions> cb) Callback<mtx::pushrules::actions::Actions> cb)
{ {
get<mtx::pushrules::actions::Actions>("/client/r0/pushrules/" + scope + "/" + kind + "/" + get<mtx::pushrules::actions::Actions>(
mtx::client::utils::url_encode(ruleId) + "/actions", "/client/r0/pushrules/" + mtx::client::utils::url_encode(scope) + "/" +
[cb](const mtx::pushrules::actions::Actions &res, mtx::client::utils::url_encode(kind) + "/" + mtx::client::utils::url_encode(ruleId) +
HeaderFields, "/actions",
RequestErr err) { cb(res, err); }); [cb](const mtx::pushrules::actions::Actions &res, HeaderFields, RequestErr err) {
cb(res, err);
});
} }
void void
...@@ -662,7 +671,9 @@ Client::put_pushrules_actions(const std::string &scope, ...@@ -662,7 +671,9 @@ Client::put_pushrules_actions(const std::string &scope,
const mtx::pushrules::actions::Actions &actions, const mtx::pushrules::actions::Actions &actions,
ErrCallback cb) ErrCallback cb)
{ {
put<mtx::pushrules::actions::Actions>("/client/r0/pushrules/" + scope + "/" + kind + "/" + put<mtx::pushrules::actions::Actions>("/client/r0/pushrules/" +
mtx::client::utils::url_encode(scope) + "/" +
mtx::client::utils::url_encode(kind) + "/" +
mtx::client::utils::url_encode(ruleId) + "/actions", mtx::client::utils::url_encode(ruleId) + "/actions",
actions, actions,
cb); cb);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment