summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNejc Habjan <nejc.habjan@siemens.com>2022-07-03 21:31:36 +0200
committerGitHub <noreply@github.com>2022-07-03 21:31:36 +0200
commit04c6063183d94fe8970bdad485cf8221db9c31a8 (patch)
treef520e01c0c697113fc706712a4fade01e2795d83
parentca3b43892996890d9c976409393ee39f66c41b75 (diff)
parent5d9c198769b00c8e7661e62aaf5f930ed32ef829 (diff)
downloadgitlab-04c6063183d94fe8970bdad485cf8221db9c31a8.tar.gz
Merge pull request #2117 from python-gitlab/jlvillal/encodedid_path
fix: ensure path elements are escaped
-rw-r--r--gitlab/base.py10
-rw-r--r--tests/functional/conftest.py2
2 files changed, 7 insertions, 5 deletions
diff --git a/gitlab/base.py b/gitlab/base.py
index 205a0f2..76524d1 100644
--- a/gitlab/base.py
+++ b/gitlab/base.py
@@ -380,10 +380,12 @@ class RESTManager:
if self._parent is None or not self._from_parent_attrs:
return path
- data = {
- self_attr: getattr(self._parent, parent_attr, None)
- for self_attr, parent_attr in self._from_parent_attrs.items()
- }
+ data: Dict[str, Optional[gitlab.utils.EncodedId]] = {}
+ for self_attr, parent_attr in self._from_parent_attrs.items():
+ if not hasattr(self._parent, parent_attr):
+ data[self_attr] = None
+ continue
+ data[self_attr] = gitlab.utils.EncodedId(getattr(self._parent, parent_attr))
self._parent_attrs = data
return path.format(**data)
diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py
index 09cdd69..22457ba 100644
--- a/tests/functional/conftest.py
+++ b/tests/functional/conftest.py
@@ -391,7 +391,7 @@ def project_file(project):
@pytest.fixture(scope="function")
def release(project, project_file):
_id = uuid.uuid4().hex
- name = f"test-release-{_id}"
+ name = f"we_have_a_slash/test-release-{_id}"
project.refresh() # Gets us the current default branch
release = project.releases.create(