From 29ce95e81e54b05b2ac63c0d5baeef1a1c3fe48f Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 29 Jul 2024 14:38:09 +0800 Subject: [PATCH] enhance: new regex for tag name (#290) * `(?!\.)` should not starts with `.` * `(?!/)` should not starts with `/` * `(?!.*\.$)` should not end with `.` * `(?!.*/$)` should not end with '/` * `(?!.*\.\.)` should not contains `..` --- src/ViewModels/CreateTag.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ViewModels/CreateTag.cs b/src/ViewModels/CreateTag.cs index 498218cb..7318e00e 100644 --- a/src/ViewModels/CreateTag.cs +++ b/src/ViewModels/CreateTag.cs @@ -12,7 +12,7 @@ namespace SourceGit.ViewModels } [Required(ErrorMessage = "Tag name is required!")] - [RegularExpression(@"^[^/]{1}[\w\-\./]*$", ErrorMessage = "Bad tag name format!")] + [RegularExpression(@"^(?!\.)(?!/)(?!.*\.$)(?!.*/$)(?!.*\.\.)[\w\-\./]+$", ErrorMessage = "Bad tag name format!")] [CustomValidation(typeof(CreateTag), nameof(ValidateTagName))] public string TagName {