Skip to content

Commit e105781

Browse files
jpinzCopilot
andauthored
Apply suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent bf47244 commit e105781

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/Microsoft.ComponentDetection.Common/DockerReference/DockerReferenceUtility.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ public static class DockerReferenceUtility
4444

4545
// Delimiters that only appear in an image reference as part of an unresolved templating
4646
// token: '$', '{' and '}' cover shell / Helm / Go-template placeholders (e.g. ${VAR},
47-
// {{ .Values.tag }}). These are recognized templating syntaxes that are expected in
48-
// un-rendered manifests, so they are skipped silently rather than reported. A token wrapped
49-
// in matching '#' or '!' (handled by DelimiterWrappedTokenRegex) is treated the same way. A
50-
// stray invalid character that is not part of such a token (e.g. a single '#' or '!') is still
51-
// reported via GetInvalidReferenceCharacters.
47+
// {{ .Values.tag }}). These are recognized templating syntaxes expected in un-rendered manifests,
48+
// so TryParseImageReference skips them (logging a warning) rather than treating them as invalid.
49+
// A token wrapped in matching '#' or '!' (handled by DelimiterWrappedTokenRegex) is treated the same way.
50+
// When no templating token is present, stray invalid characters (e.g. a single '#' or '!') are reported
51+
// via GetInvalidReferenceCharacters.
5252
private static readonly char[] TemplateDelimiters = ['$', '{', '}'];
5353

5454
// Matches token-replacement placeholders that wrap an identifier in double underscores,
@@ -310,8 +310,13 @@ private static string GetInvalidReferenceCharacters(string reference)
310310
}
311311
}
312312

313-
return string.Join(", ", invalid);
314-
}
313+
var invalidStrings = new List<string>(invalid.Count);
314+
foreach (var c in invalid)
315+
{
316+
invalidStrings.Add($"'{c}'");
317+
}
318+
319+
return string.Join(", ", invalidStrings);
315320

316321
private static DockerReference CreateDockerReference(Reference options)
317322
{

0 commit comments

Comments
 (0)