Skip to content

fix: strip leading dots and hyphens from raw tags#646

Open
zry98 wants to merge 1 commit intodocker:masterfrom
zry98:fix/raw-tag-sanitizing
Open

fix: strip leading dots and hyphens from raw tags#646
zry98 wants to merge 1 commit intodocker:masterfrom
zry98:fix/raw-tag-sanitizing

Conversation

@zry98
Copy link
Copy Markdown

@zry98 zry98 commented Apr 22, 2026

According to the Docker image tag reference, the format is /[\w][\w.-]{0,127}/, a dot (.) or hyphen (-) is not allowed as a leading character.

sanitizeTag() was already replacing illegal characters from the middle of tag names, but not for the leading characters. A given raw tag like .foo\bar would be sanitized to .foo-bar, instead of foo-bar.

This PR added a second regex replacement pass .replace(/^[^a-zA-Z0-9_]+/, '') to strip any leading dots or hyphens.

Also added 3 related tests.

Signed-off-by: zry98 <dev@zry.io>
@zry98 zry98 force-pushed the fix/raw-tag-sanitizing branch from c13d8ec to bd9134e Compare April 22, 2026 16:41
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.

1 participant