Browse Source

修正mask函数的爆破漏洞

懒得勤快 5 years ago
parent
commit
d2a680ab20
1 changed files with 2 additions and 2 deletions
  1. 2 2
      Masuit.Tools.Abstractions/Extensions/BaseType/StringExtensions.cs

+ 2 - 2
Masuit.Tools.Abstractions/Extensions/BaseType/StringExtensions.cs

@@ -159,8 +159,8 @@ namespace Masuit.Tools
                 _ when s.Length == 9 => Regex.Replace(s, "(.{2}).*(.{3})", $"$1{masks}$2"),
                 _ when s.Length == 8 => Regex.Replace(s, "(.{2}).*(.{2})", $"$1{masks}$2"),
                 _ when s.Length == 7 => Regex.Replace(s, "(.{1}).*(.{2})", $"$1{masks}$2"),
-                _ when s.Length >= 2 && s.Length < 7 => Regex.Replace(s, "(.{1}).*(.{1})", $"$1{masks}$2"),
-                _ => s + masks
+                _ when s.Length == 6 => Regex.Replace(s, "(.{1}).*(.{1})", $"$1{masks}$2"),
+                _ => Regex.Replace(s, "(.{1}).*", $"$1{masks}")
             };
         }