Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move integer validation #99

Merged
merged 1 commit into from
Oct 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions Tools/YamlCreate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,13 @@ Function Read-WinGet-InstallerManifest {
$script:InstallerSuccessCodes = PromptInstallerManifestValue $InstallerSuccessCodes 'InstallerSuccessCodes' "[Optional] List of additional non-zero installer success exit codes other than known default values by winget (Max $($Patterns.MaxItemsSuccessCodes))" | UniqueItems
if (($script:InstallerSuccessCodes -split ',').Count -le $Patterns.MaxItemsSuccessCodes) {
$script:_returnValue = [ReturnValue]::Success()
try {
#Ensure all values are integers
$script:InstallerSuccessCodes.Split(',').Trim()| ForEach-Object {[long]$_}
$script:_returnValue = [ReturnValue]::Success()
} catch {
$script:_returnValue = [ReturnValue]::new(400,"Invalid Data Type","The value entered does not match the type requirements defined in the manifest schema")
}
} else {
$script:_returnValue = [ReturnValue]::MaxItemsError($Patterns.MaxItemsSuccessCodes)
}
Expand Down Expand Up @@ -1461,14 +1468,6 @@ Function AddYamlListParameter {
)
$_Values = @()
Foreach ($Value in $Values.Split(',').Trim()) {
if ($Parameter -eq 'InstallerSuccessCodes') {
try {
$Value = [int]$Value
} catch {
# If we can't cast the value to an integer, it doesn't matter
# Continue using the value as is
}
}
$_Values += $Value
}
$Object[$Parameter] = $_Values
Expand Down Expand Up @@ -1721,7 +1720,7 @@ Function Write-Locale-Manifests {
if (!(Test-Path $AppFolder)) { New-Item -ItemType 'Directory' -Force -Path $AppFolder | Out-Null }
$script:OldLocaleManifest = ConvertFrom-Yaml -Yaml ($(Get-Content -Path $DifLocale.FullName -Encoding UTF8) -join "`n") -Ordered
$script:OldLocaleManifest['PackageVersion'] = $PackageVersion
if ($script:OldLocaleManifest.Keys -contains 'Moniker') {$script:OldLocaleManifest.Remove('Moniker')}
if ($script:OldLocaleManifest.Keys -contains 'Moniker') { $script:OldLocaleManifest.Remove('Moniker') }
$script:OldLocaleManifest = SortYamlKeys $script:OldLocaleManifest $LocaleProperties

$yamlServer = '# yaml-language-server: $schema=https://aka.ms/winget-manifest.locale.1.0.0.schema.json'
Expand Down