From 0e935d139cbf9730c1d568f86416e0112b7baf07 Mon Sep 17 00:00:00 2001 From: Sachin Shaji Date: Wed, 19 Jun 2024 10:57:30 +0530 Subject: [PATCH] fix: convert invalid uri regex --- capycli/common/capycli_bom_support.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/capycli/common/capycli_bom_support.py b/capycli/common/capycli_bom_support.py index a4ca32a..0a3be80 100644 --- a/capycli/common/capycli_bom_support.py +++ b/capycli/common/capycli_bom_support.py @@ -10,6 +10,7 @@ import os import pathlib import uuid +import re from datetime import datetime from enum import Enum from typing import Any, Dict, Iterable, List, Optional, Union @@ -355,9 +356,14 @@ def get_ext_ref(comp: Component, type: ExternalReferenceType, comment: str) -> O @staticmethod def set_ext_ref(comp: Component, type: ExternalReferenceType, comment: str, value: str, hash_algo: str = "", hash: str = "") -> None: + + if re.search(XsUri._INVALID_URI_REGEX, str(value)): + cleaned_uri = re.sub(XsUri._INVALID_URI_REGEX, ':', str(value)) + else: + cleaned_uri = str(value) ext_ref = ExternalReference( reference_type=type, - url=XsUri(value), + url=XsUri(cleaned_uri), comment=comment) if hash_algo and hash: