From 589c58adb0f805ca32627794a597d20280b80c9f Mon Sep 17 00:00:00 2001 From: Sauceke Date: Sat, 2 Sep 2023 18:53:30 +0200 Subject: [PATCH] [Fix] URL encode timestamps sent as query parameters (#2770) * [Fix] URL encode timestamps sent as query parameters --- src/Discord.Net.Rest/DiscordRestApiClient.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index dc748e26..e9b0c157 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -618,11 +618,13 @@ namespace Discord.API if (limit.HasValue) { - query = $"?before={before.GetValueOrDefault(DateTimeOffset.UtcNow).ToString("O")}&limit={limit.Value}"; + string beforeEncoded = WebUtility.UrlEncode(before.GetValueOrDefault(DateTimeOffset.UtcNow).ToString("O")); + query = $"?before={beforeEncoded}&limit={limit.Value}"; } else if (before.HasValue) { - query = $"?before={before.Value.ToString("O")}"; + string beforeEncoded = WebUtility.UrlEncode(before.Value.ToString("O")); + query = $"?before={beforeEncoded}"; } return await SendAsync("GET", () => $"channels/{channelId}/threads/archived/public{query}", bucket, options: options); @@ -641,11 +643,13 @@ namespace Discord.API if (limit.HasValue) { - query = $"?before={before.GetValueOrDefault(DateTimeOffset.UtcNow).ToString("O")}&limit={limit.Value}"; + string beforeEncoded = WebUtility.UrlEncode(before.GetValueOrDefault(DateTimeOffset.UtcNow).ToString("O")); + query = $"?before={beforeEncoded}&limit={limit.Value}"; } else if (before.HasValue) { - query = $"?before={before.Value.ToString("O")}"; + string beforeEncoded = WebUtility.UrlEncode(before.Value.ToString("O")); + query = $"?before={beforeEncoded}"; } return await SendAsync("GET", () => $"channels/{channelId}/threads/archived/private{query}", bucket, options: options);