+ fix: hardening commit_id.txt file input for version string assembling

This commit is contained in:
Rainer Kottenhoff 2020-06-18 11:07:31 +02:00
parent e8fe78e241
commit c2efb99ab1

View File

@ -58,6 +58,7 @@ try
$Build = $Build + 1
# locally: we have no commit ID, create an arificial one
$CommitID = [string](Get-Content "Versions\commit_id.txt")
if (!$CommitID) { $CommitID = "---" }
if ($CommitID -eq "computername") {
$length = ([string]($env:computername)).length
$CommitID = ([string]($env:computername)).substring(0,[math]::min($length,8)).ToLower()
@ -68,6 +69,9 @@ try
}
}
if (!$CommitID) { $CommitID = "---" }
$CommitID = $CommitID -replace '"', ''
$CommitID = $CommitID -replace "'", ''
if (!$CommitID) { $CommitID = "---" }
$Build | Set-Content "Versions\build.txt"
$CompleteVer = "$Major.$Minor.$Revis.$Build"