Skip to content

Commit 1398426

Browse files
committed
fix(client): ensure encoded query params are never duplicated
1 parent 6f71c66 commit 1398426

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

gitlab/client.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import re
2121
import time
2222
from typing import Any, cast, Dict, List, Optional, Tuple, TYPE_CHECKING, Union
23+
from urllib import parse
2324

2425
import requests
2526
import requests.utils
@@ -677,11 +678,15 @@ def http_request(
677678
GitlabHttpError: When the return code is not 2xx
678679
"""
679680
query_data = query_data or {}
680-
url = self._build_url(path)
681+
raw_url = self._build_url(path)
681682

682-
params: Dict[str, Any] = {}
683+
# parse user-provided URL params to ensure we don't add our own duplicates
684+
parsed = parse.urlparse(raw_url)
685+
params = parse.parse_qs(parsed.query)
683686
utils.copy_dict(src=query_data, dest=params)
684687

688+
url = raw_url.replace(parsed.query, "").strip("?")
689+
685690
# Deal with kwargs: by default a user uses kwargs to send data to the
686691
# gitlab server, but this generates problems (python keyword conflicts
687692
# and python-gitlab/gitlab conflicts).

0 commit comments

Comments
 (0)