Use System.Xml.XmlDocument.Load rather than Get-Content to avoid (#49206)

encoding errors when writing out XML

removing executable bit

refactor tests to handle sanity checking
This commit is contained in:
Richard Levenberg 2018-12-04 07:19:38 -08:00 committed by jhawkesworth
commit 5cb39d0d57
4 changed files with 62 additions and 8 deletions

View file

@ -107,9 +107,10 @@ If (-Not (Test-Path -Path $dest -PathType Leaf)){
Fail-Json $result "Specified path $dest does not exist or is not a file."
}
[xml]$xmlorig = $null
$xmlorig = New-Object -TypeName System.Xml.XmlDocument
$xmlorig.XmlResolver = $null
Try {
[xml]$xmlorig = Get-Content -Path $dest
$xmlorig.Load($dest)
}
Catch {
Fail-Json $result "Failed to parse file at '$dest' as an XML document: $($_.Exception.Message)"