Merge pull request #439 from gnieto/fix/url-escape

fix: urlencode since opaque string
This commit is contained in:
Kegan Dougal 2024-05-20 13:12:46 +01:00 committed by GitHub
commit d5b3e4b33d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -152,7 +152,7 @@ func (v *HTTPClient) createSyncURL(since string, isFirst, toDeviceOnly bool) str
qps += "timeout=30000" qps += "timeout=30000"
} }
if since != "" { if since != "" {
qps += "&since=" + since qps += "&since=" + url.QueryEscape(since)
} }
// Set presence to offline, this potentially reduces CPU load on upstream homeservers // Set presence to offline, this potentially reduces CPU load on upstream homeservers

View File

@ -65,6 +65,12 @@ func TestSyncURL(t *testing.T) {
toDeviceOnly: true, toDeviceOnly: true,
wantURL: wantBaseURL + `?timeout=0&since=112233&set_presence=offline&filter=` + url.QueryEscape(`{"presence":{"not_types":["*"]},"room":{"rooms":[],"timeline":{"limit":50}}}`), 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 { for i, tc := range testCases {
gotURL := client.createSyncURL(tc.since, tc.isFirst, tc.toDeviceOnly) gotURL := client.createSyncURL(tc.since, tc.isFirst, tc.toDeviceOnly)