Skip to content

Commit 0536e25

Browse files
committed
Limit the width on all Out-String calls to that of a 16-bit signed integer.
We had an issue with this in `Resolve-ADTErrorRecord`. Best that we apply this consistently everywhere.
1 parent 0714b2a commit 0536e25

11 files changed

Lines changed: 12 additions & 12 deletions

File tree

examples/Multi-session Installation/Invoke-AppDeployToolkit.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ try
198198
}
199199
catch
200200
{
201-
$Host.UI.WriteErrorLine((Out-String -InputObject $_ -Width ([System.Int32]::MaxValue)))
201+
$Host.UI.WriteErrorLine((Out-String -InputObject $_ -Width ([System.Int16]::MaxValue)))
202202
exit 60008
203203
}
204204

examples/VLC/Invoke-AppDeployToolkit.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ try
321321
}
322322
catch
323323
{
324-
$Host.UI.WriteErrorLine((Out-String -InputObject $_ -Width ([System.Int32]::MaxValue)))
324+
$Host.UI.WriteErrorLine((Out-String -InputObject $_ -Width ([System.Int16]::MaxValue)))
325325
exit 60008
326326
}
327327

examples/WinSCP/Invoke-AppDeployToolkit.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ try
330330
}
331331
catch
332332
{
333-
$Host.UI.WriteErrorLine((Out-String -InputObject $_ -Width ([System.Int32]::MaxValue)))
333+
$Host.UI.WriteErrorLine((Out-String -InputObject $_ -Width ([System.Int16]::MaxValue)))
334334
exit 60008
335335
}
336336

src/PSAppDeployToolkit.Build/Private/Invoke-ADTMarkdownExport.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function Invoke-ADTMarkdownExport
201201
{
202202
for ($i = 0; $i -lt $MissingDocumentation.Count; $i++)
203203
{
204-
$output = ($MissingDocumentation[$i] | Select-Object -Property FileName, LineNumber, Line | Format-List -Property * | Out-String -Width ([System.Int32]::MaxValue)).Trim().Split([System.String[]]("`r`n", "`n"), [System.StringSplitOptions]::None).Trim() -replace '^', "> "
204+
$output = ($MissingDocumentation[$i] | Select-Object -Property FileName, LineNumber, Line | Format-List -Property * | Out-String -Width ([System.Int16]::MaxValue)).Trim().Split([System.String[]]("`r`n", "`n"), [System.StringSplitOptions]::None).Trim() -replace '^', "> "
205205
Write-ADTBuildLogEntry -Message "Output for missing documentation MatchInfo [$($i+1)/$($MissingDocumentation.Count)]" -ForegroundColor DarkRed
206206
Write-ADTBuildLogEntry -Message $output -ForegroundColor DarkRed
207207
}

src/PSAppDeployToolkit.Build/Private/Write-ADTScriptAnalyzerOutput.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function Write-ADTScriptAnalyzerOutput
1717
# Write each result out to the console.
1818
for ($i = 0; $i -lt $DiagnosticRecord.Count; $i++)
1919
{
20-
$output = ($DiagnosticRecord[$i] | Format-List -Property * | Out-String -Width ([System.Int32]::MaxValue)).Split([System.String[]]("`r`n", "`n"), [System.StringSplitOptions]::None).Trim() -replace '^', "> "
20+
$output = ($DiagnosticRecord[$i] | Format-List -Property * | Out-String -Width ([System.Int16]::MaxValue)).Split([System.String[]]("`r`n", "`n"), [System.StringSplitOptions]::None).Trim() -replace '^', "> "
2121
Write-ADTBuildLogEntry -Message "Output for Invoke-ScriptAnalyzer DiagnosticRecord [$($i+1)/$($DiagnosticRecord.Count)]" -ForegroundColor DarkRed
2222
Write-ADTBuildLogEntry -Message $output -ForegroundColor DarkRed
2323
}

src/PSAppDeployToolkit/Public/Get-ADTPendingReboot.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function Get-ADTPendingReboot
137137
$PendingFileRenameOperations,
138138
$PendRebootErrorMsg.AsReadOnly()
139139
)
140-
Write-ADTLogEntry -Message "Pending reboot status on the local computer [$HostName]:`n$($PendingRebootInfo | Format-List | Out-String -Width ([System.Int32]::MaxValue))"
140+
Write-ADTLogEntry -Message "Pending reboot status on the local computer [$HostName]:`n$($PendingRebootInfo | Format-List | Out-String -Width ([System.Int16]::MaxValue))"
141141
return $PendingRebootInfo
142142
}
143143
catch

src/PSAppDeployToolkit/Public/Initialize-ADTFunction.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function Initialize-ADTFunction
9494
Write-ADTLogEntry -Message 'Function Start' -Source $Cmdlet.MyInvocation.MyCommand.Name -DebugMessage
9595
if ($Cmdlet.MyInvocation.BoundParameters.Count)
9696
{
97-
$CmdletBoundParameters = $Cmdlet.MyInvocation.BoundParameters | Format-Table -Property @{ Label = 'Parameter'; Expression = { "[-$($_.Key)]" } }, @{ Label = 'Value'; Expression = { $_.Value }; Alignment = 'Left' }, @{ Label = 'Type'; Expression = { if ($_.Value) { $_.Value.GetType().Name } }; Alignment = 'Left' } -AutoSize -Wrap | Out-String -Width ([System.Int32]::MaxValue)
97+
$CmdletBoundParameters = $Cmdlet.MyInvocation.BoundParameters | Format-Table -Property @{ Label = 'Parameter'; Expression = { "[-$($_.Key)]" } }, @{ Label = 'Value'; Expression = { $_.Value }; Alignment = 'Left' }, @{ Label = 'Type'; Expression = { if ($_.Value) { $_.Value.GetType().Name } }; Alignment = 'Left' } -AutoSize -Wrap | Out-String -Width ([System.Int16]::MaxValue)
9898
Write-ADTLogEntry -Message "Function invoked with bound parameter(s):`n$CmdletBoundParameters" -Source $Cmdlet.MyInvocation.MyCommand.Name -DebugMessage
9999
}
100100
else

src/PSAppDeployToolkit/Public/New-ADTTemplate.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ function New-ADTTemplate
210210
LiteralPath = "$templatePath\Invoke-AppDeployToolkit.ps1"
211211
Encoding = ('utf8', 'utf8BOM')[$PSVersionTable.PSEdition.Equals('Core')]
212212
}
213-
Out-File -InputObject (Get-Content @params -Raw).Replace('..\..\..\..\', [System.Management.Automation.Language.NullString]::Value).Replace('2000-12-31', [System.DateTime]::Now.ToString('O').Split('T')[0]) @params -Width ([System.Int32]::MaxValue) -Force
213+
Out-File -InputObject (Get-Content @params -Raw).Replace('..\..\..\..\', [System.Management.Automation.Language.NullString]::Value).Replace('2000-12-31', [System.DateTime]::Now.ToString('O').Split('T')[0]) @params -Width ([System.Int16]::MaxValue) -Force
214214
}
215215
else
216216
{

src/PSAppDeployToolkit/Public/Resolve-ADTErrorRecord.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ function Resolve-ADTErrorRecord
200200
}
201201

202202
# Build out error properties.
203-
$logErrorMessage = [System.String]::Join([System.Environment]::NewLine, "Error Record:", "-------------", $null, (Out-String -InputObject (Format-List -InputObject ([pscustomobject]$logErrorProperties)) -Width ([System.Int32]::MaxValue)).Trim())
203+
$logErrorMessage = [System.String]::Join([System.Environment]::NewLine, "Error Record:", "-------------", $null, (Out-String -InputObject (Format-List -InputObject ([pscustomobject]$logErrorProperties)) -Width ([System.Int16]::MaxValue)).Trim())
204204

205205
# Capture Error Inner Exception(s).
206206
if ($IncludeErrorInnerException -and $ErrorRecord.Exception -and $ErrorRecord.Exception.InnerException)
@@ -219,7 +219,7 @@ function Resolve-ADTErrorRecord
219219
}
220220

221221
# Add error record and get next inner exception.
222-
$innerExceptions.Add(($errInnerException | Select-Object -Property ($errInnerException | Get-ErrorPropertyNames) | Format-List | Out-String -Width ([System.Int32]::MaxValue)).Trim())
222+
$innerExceptions.Add(($errInnerException | Select-Object -Property ($errInnerException | Get-ErrorPropertyNames) | Format-List | Out-String -Width ([System.Int16]::MaxValue)).Trim())
223223
$errInnerException = $errInnerException.InnerException
224224
}
225225

src/PSAppDeployToolkit/Public/Show-ADTHelpConsole.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function Show-ADTHelpConsole
6666
$help = [System.Collections.Generic.Dictionary[System.String, System.String]]::new()
6767
foreach ($exportedCommand in $_.ExportedCommands.Keys)
6868
{
69-
$help.Add($exportedCommand, [System.String]::Join([System.Environment]::NewLine, ((Get-Help -Name $exportedCommand -Full | Out-String -Width ([System.Int32]::MaxValue) -Stream) -replace '^\s+$').TrimEnd()).Trim().Replace('<br />', [System.Management.Automation.Language.NullString]::Value) + [System.Environment]::NewLine)
69+
$help.Add($exportedCommand, [System.String]::Join([System.Environment]::NewLine, ((Get-Help -Name $exportedCommand -Full | Out-String -Width ([System.Int16]::MaxValue) -Stream) -replace '^\s+$').TrimEnd()).Trim().Replace('<br />', [System.Management.Automation.Language.NullString]::Value) + [System.Environment]::NewLine)
7070
}
7171

7272
# Add the dictionary of commands and their help to the collector.

0 commit comments

Comments
 (0)