From 7b014b1c0c055ccf3a8aff911020cfc8740aa6d7 Mon Sep 17 00:00:00 2001 From: Karl Kauc Date: Mon, 18 May 2026 09:37:05 +0200 Subject: [PATCH] fix(powershell): tolerate quoted/padded FUNDSXML_SCHEMA_DIR cmd's `set VAR="x"` keeps the quotes in the value; the stray " is an illegal Windows path character and made Test-Path throw before the not-found check, aborting validation. Trim surrounding quotes and whitespace from the env var so the documented corporate escape hatch tolerates this common shell mistake. Co-Authored-By: Claude Opus 4.7 (1M context) --- XSD_Validation/powershell/Validate-FundsXml.ps1 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/XSD_Validation/powershell/Validate-FundsXml.ps1 b/XSD_Validation/powershell/Validate-FundsXml.ps1 index f2b7b08..cfaa208 100644 --- a/XSD_Validation/powershell/Validate-FundsXml.ps1 +++ b/XSD_Validation/powershell/Validate-FundsXml.ps1 @@ -46,8 +46,15 @@ function Get-File($url, $dest) { Invoke-WebRequest -Uri $url -OutFile $dest -MaximumRedirection 5 -UseBasicParsing } -if ($env:FUNDSXML_SCHEMA_DIR) { - $schemaPath = Join-Path $env:FUNDSXML_SCHEMA_DIR 'FundsXML.xsd' +# cmd's `set VAR="x"` keeps the quotes in the value; a stray " is an +# illegal path char and crashes Test-Path. Trim quotes/whitespace so the +# escape hatch tolerates that common mistake. +$schemaDirEnv = if ($env:FUNDSXML_SCHEMA_DIR) { + $env:FUNDSXML_SCHEMA_DIR.Trim().Trim('"', "'") +} else { '' } + +if ($schemaDirEnv) { + $schemaPath = Join-Path $schemaDirEnv 'FundsXML.xsd' if (-not (Test-Path $schemaPath)) { Write-Error "FUNDSXML_SCHEMA_DIR set but $schemaPath not found"; exit 2 }