Merge pull request #4506 from SALTWOOD/main

通过检测 NTFS 8.3 文件名修复 #4505
This commit is contained in:
Hex Dragon Bot
2024-10-13 04:41:47 +08:00
committed by GitHub
2 changed files with 17 additions and 1 deletions
@@ -1717,6 +1717,16 @@ RetryDir:
Public Function RegexReplaceEach(Input As String, Replacement As MatchEvaluator, Regex As String, Optional options As RegexOptions = RegularExpressions.RegexOptions.None) As String
Return RegularExpressions.Regex.Replace(Input, Regex, Replacement, options)
End Function
''' <summary>
''' 检查传入字符串会不会引发 Issue #4505
''' </summary>
Public Function Ntfs83NameCheck(name As String) As Boolean
Dim regex As New Regex("(.*)~(\d*)")
Dim namePart As Byte() = Encoding.UTF8.GetBytes(regex.Match(name).Groups(1).Value)
Dim numPart As Integer = regex.Match(name).Groups(2).Value.Length
Return namePart.Length >= 6 AndAlso numPart = 1
End Function
#End Region