Skip to content

Commit

Permalink
fix(client): ensure encoded query params are never duplicated
Browse files Browse the repository at this point in the history
  • Loading branch information
nejch committed Aug 4, 2022
1 parent 6f71c66 commit 1398426
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gitlab/client.py
Expand Up @@ -20,6 +20,7 @@
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
Expand Down Expand Up @@ -677,11 +678,15 @@ def http_request(
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).
Expand Down

0 comments on commit 1398426

Please sign in to comment.