Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/validation/uri_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
url_pattern_ignore_case = re.compile(url_pattern, re.IGNORECASE)

supported_download_repos: str = "(git|hg|svn|bzr)"
git_pattern = "(git\\+git@[a-zA-Z0-9\\.\\-]+:[a-zA-Z0-9/\\\\.@\\-]+)"
git_pattern = "(git\\+git@[a-zA-Z0-9\\.\\-]+:[a-zA-Z0-9/\\\\.@\\-_]+)"
bazaar_pattern = "(bzr\\+lp:[a-zA-Z0-9\\.\\-]+)"
download_location_pattern = (
"^(((" + supported_download_repos + "\\+)?" + url_pattern + ")|" + git_pattern + "|" + bazaar_pattern + ")$"
Expand Down
15 changes: 12 additions & 3 deletions tests/spdx/validation/test_uri_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

import pytest

from spdx_tools.spdx.validation.uri_validators import validate_download_location, validate_uri, validate_url
from spdx_tools.spdx.validation.uri_validators import (
validate_download_location,
validate_uri,
validate_url,
)


@pytest.mark.parametrize(
Expand Down Expand Up @@ -81,6 +85,7 @@ def test_invalid_url(input_value):
"bzr+http://bzr.myproject.org/MyProject/trunk@v1.0",
"bzr+https://bzr.myproject.org/MyProject/trunk@2019#src/somefile.c",
"BZR+HTTPS://BZR.MYPROJECT.ORG/MYPROJECT/TRUNK@2019#SRC/SOMEFILE.C",
"git+git@github.com:zephyrproject-rtos/CMSIS_6@06d952b6713a2ca41c9224a62075e4059402a151-off",
],
)
def test_valid_package_download_location(input_value):
Expand Down Expand Up @@ -118,7 +123,8 @@ def test_valid_uri(input_value):


@pytest.mark.parametrize(
"input_value", ["/invalid/uri", "http//uri", "http://some#uri", "some/uri", "some weird test"]
"input_value",
["/invalid/uri", "http//uri", "http://some#uri", "some/uri", "some weird test"],
)
def test_invalid_uri(input_value):
message = validate_uri(input_value)
Expand All @@ -128,7 +134,10 @@ def test_invalid_uri(input_value):
]


@pytest.mark.parametrize("input_value", ["://spdx.org/spdxdocs/spdx-tools-v1.2-3F2504E0-4F89-41D3-9A0C-0305E82..."])
@pytest.mark.parametrize(
"input_value",
["://spdx.org/spdxdocs/spdx-tools-v1.2-3F2504E0-4F89-41D3-9A0C-0305E82..."],
)
@pytest.mark.skip(
"validate_uri() seems to invalidate URIs without scheme, so it does not run into this case. But I'm not sure yet "
"if this covers all scheme-less examples."
Expand Down