Skip to content
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

Sanitize layer names in from_images #1016

Merged
merged 2 commits into from
Mar 14, 2024
Merged

Conversation

markbader
Copy link
Contributor

@markbader markbader commented Mar 12, 2024

Description:

  • in WEBKNOSSOS layer names have to match the pattern [A-Za-z0-9_\-\.]*. This wasn't ensured by wklibs yet. This PR adds a check for correct layer names in the add_layer method and sanitizes the generated layer names of from_images.

Todos:

Make sure to delete unnecessary points or to check all before merging:

  • Updated Changelog
  • Added / Updated Tests

@markbader markbader requested a review from fm3 March 12, 2024 13:14
@markbader markbader self-assigned this Mar 12, 2024
assert _ALLOWED_LAYER_NAME_REGEX.match(
layer_name
), f"The layer name '{layer_name}' is invalid. It must only contain letters, numbers, underscores, hyphens and dots."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this also check the does-not-start-with-dort condition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the _ALLOWED_LAYER_NAME_REGEX checks that at least one allowed character that is not a dot has to be at the beginning of the string.

@markbader markbader merged commit 76d2326 into master Mar 14, 2024
19 checks passed
@markbader markbader deleted the restrict_chars_for_layer_naming branch March 14, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants