Fixed some filename and path validation problems
This commit is contained in:
@@ -38,7 +38,7 @@ Public Class clsGame
|
||||
Property ID As String
|
||||
Set(value As String)
|
||||
If Not value Is Nothing Then
|
||||
sGameID = mgrPath.ValidateForFileSystem(value)
|
||||
sGameID = mgrPath.ValidateFileNameForOS(value)
|
||||
End If
|
||||
End Set
|
||||
Get
|
||||
@@ -64,7 +64,7 @@ Public Class clsGame
|
||||
|
||||
ReadOnly Property FileSafeName As String
|
||||
Get
|
||||
Return mgrPath.ValidateForFileSystem(sGameName)
|
||||
Return mgrPath.ValidateFileNameForOS(sGameName)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
|
||||
+14
-11
@@ -1204,20 +1204,24 @@ Public Class frmGameManager
|
||||
If txtID.Text <> String.Empty Then
|
||||
oApp.ID = txtID.Text
|
||||
End If
|
||||
|
||||
oApp.Name = txtName.Text
|
||||
If Path.HasExtension(txtProcess.Text) Then
|
||||
If txtProcess.Text.ToLower.EndsWith(".exe") Then
|
||||
oApp.ProcessName = Path.GetFileNameWithoutExtension(txtProcess.Text)
|
||||
Else
|
||||
oApp.ProcessName = txtProcess.Text
|
||||
oApp.IsRegEx = chkRegEx.Checked
|
||||
|
||||
If Not oApp.IsRegEx Then
|
||||
txtProcess.Text = mgrPath.ValidateFileNameForOS(txtProcess.Text)
|
||||
If Path.HasExtension(txtProcess.Text) Then
|
||||
If txtProcess.Text.ToLower.EndsWith(".exe") Then
|
||||
txtProcess.Text = Path.GetFileNameWithoutExtension(txtProcess.Text)
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
oApp.ProcessName = txtProcess.Text
|
||||
End If
|
||||
|
||||
oApp.ProcessName = txtProcess.Text
|
||||
oApp.Parameter = txtParameter.Text
|
||||
oApp.Path = txtSavePath.Text
|
||||
oApp.Path = mgrPath.ValidatePathForOS(txtSavePath.Text)
|
||||
'Only do a simple root check here in case the user doesn't really understand creating a proper configuration
|
||||
oApp.AbsolutePath = Path.IsPathRooted(txtSavePath.Text)
|
||||
oApp.AbsolutePath = Path.IsPathRooted(oApp.Path)
|
||||
oApp.FileType = txtFileType.Text
|
||||
oApp.ExcludeList = txtExclude.Text
|
||||
oApp.FolderSave = chkFolderSave.Checked
|
||||
@@ -1225,10 +1229,9 @@ Public Class frmGameManager
|
||||
oApp.AppendTimeStamp = chkTimeStamp.Checked
|
||||
oApp.BackupLimit = nudLimit.Value
|
||||
oApp.Comments = txtComments.Text
|
||||
oApp.IsRegEx = chkRegEx.Checked
|
||||
oApp.Enabled = chkEnabled.Checked
|
||||
oApp.MonitorOnly = chkMonitorOnly.Checked
|
||||
oApp.ProcessPath = txtAppPath.Text
|
||||
oApp.ProcessPath = mgrPath.ValidatePathForOS(txtAppPath.Text)
|
||||
oApp.Company = txtCompany.Text
|
||||
oApp.Version = txtVersion.Text
|
||||
oApp.Icon = txtIcon.Text
|
||||
|
||||
+12
-2
@@ -99,8 +99,18 @@ Public Class mgrPath
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Shared Function ValidateForFileSystem(ByVal sCheckString As String) As String
|
||||
Dim cInvalidCharacters As Char() = {"\", "/", ":", "*", "?", """", "<", ">", "|", "."}
|
||||
Public Shared Function ValidatePathForOS(ByVal sCheckString As String) As String
|
||||
Dim cInvalidCharacters As Char() = Path.GetInvalidPathChars
|
||||
|
||||
For Each c As Char In cInvalidCharacters
|
||||
sCheckString = sCheckString.Replace(c, "")
|
||||
Next
|
||||
|
||||
Return sCheckString.Trim
|
||||
End Function
|
||||
|
||||
Public Shared Function ValidateFileNameForOS(ByVal sCheckString As String) As String
|
||||
Dim cInvalidCharacters As Char() = Path.GetInvalidFileNameChars
|
||||
|
||||
For Each c As Char In cInvalidCharacters
|
||||
sCheckString = sCheckString.Replace(c, "")
|
||||
|
||||
Reference in New Issue
Block a user