Skip to content

fix: handle tags like debian/2%2.6-21 as identifiers #1336

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
Mar 6, 2021
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
8 changes: 8 additions & 0 deletions gitlab/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def test_clean_str_id():
dest = "foo%23bar%2Fbaz%2F"
assert dest == utils.clean_str_id(src)

src = "foo%bar/baz/"
dest = "foo%25bar%2Fbaz%2F"
assert dest == utils.clean_str_id(src)


def test_sanitized_url():
src = "http://localhost/foo/bar"
Expand All @@ -48,6 +52,10 @@ def test_sanitize_parameters_slash():
assert "foo%2Fbar" == utils.sanitize_parameters("foo/bar")


def test_sanitize_parameters_slash_and_percent():
assert "foo%2Fbar%25quuz" == utils.sanitize_parameters("foo/bar%quuz")


def test_sanitize_parameters_dict():
source = {"url": "foo/bar", "id": 1}
expected = {"url": "foo%2Fbar", "id": 1}
Expand Down
6 changes: 3 additions & 3 deletions gitlab/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from typing import Any, Callable, Dict, Optional
from urllib.parse import urlparse
from urllib.parse import quote, urlparse

import requests

Expand Down Expand Up @@ -57,14 +57,14 @@ def copy_dict(dest: Dict[str, Any], src: Dict[str, Any]) -> None:


def clean_str_id(id: str) -> str:
return id.replace("/", "%2F").replace("#", "%23")
return quote(id, safe="")


def sanitize_parameters(value):
if isinstance(value, dict):
return dict((k, sanitize_parameters(v)) for k, v in value.items())
if isinstance(value, str):
return value.replace("/", "%2F")
return quote(value, safe="")
return value


Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy