Skip to content

fix: ensure path elements are escaped #2117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions gitlab/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,12 @@ def _compute_path(self, path: Optional[str] = None) -> Optional[str]:
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)

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down