Skip to content

Commit

Permalink
Merge pull request #439 from gnieto/fix/url-escape
Browse files Browse the repository at this point in the history
fix: urlencode since opaque string
  • Loading branch information
kegsay authored May 20, 2024
2 parents 425a5d4 + 45f3e01 commit d5b3e4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sync2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (v *HTTPClient) createSyncURL(since string, isFirst, toDeviceOnly bool) str
qps += "timeout=30000"
}
if since != "" {
qps += "&since=" + since
qps += "&since=" + url.QueryEscape(since)
}

// Set presence to offline, this potentially reduces CPU load on upstream homeservers
Expand Down
6 changes: 6 additions & 0 deletions sync2/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ func TestSyncURL(t *testing.T) {
toDeviceOnly: true,
wantURL: wantBaseURL + `?timeout=0&since=112233&set_presence=offline&filter=` + url.QueryEscape(`{"presence":{"not_types":["*"]},"room":{"rooms":[],"timeline":{"limit":50}}}`),
},
{
since: "112233#145",
isFirst: true,
toDeviceOnly: true,
wantURL: wantBaseURL + `?timeout=0&since=112233%23145&set_presence=offline&filter=` + url.QueryEscape(`{"presence":{"not_types":["*"]},"room":{"rooms":[],"timeline":{"limit":50}}}`),
},
}
for i, tc := range testCases {
gotURL := client.createSyncURL(tc.since, tc.isFirst, tc.toDeviceOnly)
Expand Down

0 comments on commit d5b3e4b

Please sign in to comment.