From 0ee1b3a5daa19cb53596bb5fb3626ab9d5d89130 Mon Sep 17 00:00:00 2001 From: Samir Bioud Date: Fri, 27 Jun 2025 22:34:21 +0100 Subject: [PATCH] Fix: Bad docker image name prefix pruning If a workspace name started with _ or ., the generated docker image name segment would be invalid due to `-_` or `-.` sequences, this code simply extends the postfix pruning code to also prune these prefixes --- src/docker/custom.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/docker/custom.rs b/src/docker/custom.rs index 4e2a4245e..b310bdd42 100644 --- a/src/docker/custom.rs +++ b/src/docker/custom.rs @@ -266,7 +266,13 @@ fn docker_tag_name(file_name: &str) -> String { // in case our result ends in an invalid last char `-` or `.` // we remove - result = result.trim_end_matches(&['.', '-']).to_owned(); + // in case our result starts in a `_`, we trim it + // as this otherwise clashes with the `-` prefix, leading to + // the invalid sequence `-_` + result = result + .trim_end_matches(['.', '-']) + .trim_start_matches(['.', '_']) + .to_owned(); // in case all characters were invalid or we had all non-ASCII // characters followed by a `-` or `.`, we use a non-empty filename