From 18535bb4c754f7f06de2477b5562d41a3f666db9 Mon Sep 17 00:00:00 2001 From: vi <8530778+shiftinv@users.noreply.github.com> Date: Sun, 29 Dec 2024 18:05:40 +0100 Subject: [PATCH] fix(http): escape `/` in url parameters (#1264) --- changelog/1264.bugfix.rst | 1 + disnake/http.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelog/1264.bugfix.rst diff --git a/changelog/1264.bugfix.rst b/changelog/1264.bugfix.rst new file mode 100644 index 0000000000..417429388e --- /dev/null +++ b/changelog/1264.bugfix.rst @@ -0,0 +1 @@ +Escape forward slashes in HTTP route parameters. diff --git a/disnake/http.py b/disnake/http.py index 4d3132c2ea..b258985016 100644 --- a/disnake/http.py +++ b/disnake/http.py @@ -177,7 +177,11 @@ def __init__(self, method: str, path: str, **parameters: Any) -> None: url = self.BASE + self.path if parameters: url = url.format_map( - {k: _uriquote(v) if isinstance(v, str) else v for k, v in parameters.items()} + { + # `/` should not be considered a safe character by default + k: _uriquote(v, safe="") if isinstance(v, str) else v + for k, v in parameters.items() + } ) self.url: str = url