-
Notifications
You must be signed in to change notification settings - Fork 7
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
fix: convert invalid uri regex #71
Conversation
@sachinshaji Thanks a lot for fixing. |
@sachinshaji, sorry for the late answer here! I finally had a chance to have a look on #70 and your fix here and I'm a bit confused. Perhaps you can explain this a bit better? |
@@ -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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I get this right, XsUri._INVALID_URI_REGEX
mainly checks for invalid percent encoding in a URL, so I'm not sure how this would apply to #70. Also, I'm a bit confused why you replace invalid URL parts with a ":" here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @gernot-h Try to take a look at the original CycloneDX code of XsUri. They do this check and then throw an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did, and I don't yet see how replacing invalid percent encoding by ":" can help here, but I will try to reproduce #70 as you suggested and then debug it on myself. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated fix available in #72.
This PR is to address this issue.
@gernot-h Please have a look.