summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNejc Habjan <nejc.habjan@siemens.com>2022-08-04 15:36:47 +0200
committerNejc Habjan <nejc.habjan@siemens.com>2022-08-04 15:36:47 +0200
commit1398426cd748fdf492fe6184b03ac2fcb7e4fd6e (patch)
tree27f0385b26ad3736d8846b91696b5dc80681ccf8
parent6f71c663a302b20632558b4c94be428ba831ee7f (diff)
downloadgitlab-1398426cd748fdf492fe6184b03ac2fcb7e4fd6e.tar.gz
fix(client): ensure encoded query params are never duplicated
-rw-r--r--gitlab/client.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/gitlab/client.py b/gitlab/client.py
index dc6b6e6..b3223e5 100644
--- a/gitlab/client.py
+++ b/gitlab/client.py
@@ -20,6 +20,7 @@ import os
import re
import time
from typing import Any, cast, Dict, List, Optional, Tuple, TYPE_CHECKING, Union
+from urllib import parse
import requests
import requests.utils
@@ -677,11 +678,15 @@ class Gitlab:
GitlabHttpError: When the return code is not 2xx
"""
query_data = query_data or {}
- url = self._build_url(path)
+ raw_url = self._build_url(path)
- params: Dict[str, Any] = {}
+ # parse user-provided URL params to ensure we don't add our own duplicates
+ parsed = parse.urlparse(raw_url)
+ params = parse.parse_qs(parsed.query)
utils.copy_dict(src=query_data, dest=params)
+ url = raw_url.replace(parsed.query, "").strip("?")
+
# Deal with kwargs: by default a user uses kwargs to send data to the
# gitlab server, but this generates problems (python keyword conflicts
# and python-gitlab/gitlab conflicts).