From 2771424c71ff4a477c0883f77a99f39835856430 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Sun, 8 Feb 2026 18:18:24 +0300 Subject: [PATCH] Fix XML escaping in mxl-compile text content Add Esc-Xml helper to escape &, <, >, " in cell text and template content to prevent invalid XML generation. Co-Authored-By: Claude Opus 4.6 --- .claude/skills/mxl-compile/scripts/mxl-compile.ps1 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.claude/skills/mxl-compile/scripts/mxl-compile.ps1 b/.claude/skills/mxl-compile/scripts/mxl-compile.ps1 index e946637d..445917e8 100644 --- a/.claude/skills/mxl-compile/scripts/mxl-compile.ps1 +++ b/.claude/skills/mxl-compile/scripts/mxl-compile.ps1 @@ -226,6 +226,12 @@ foreach ($col in $colWidthMap.Keys) { # 6c. Scan areas for row heights and cell formats # We need to do two passes: first collect all formats, then generate XML +# Helper: escape XML special characters +function Esc-Xml { + param([string]$s) + return $s.Replace('&','&').Replace('<','<').Replace('>','>').Replace('"','"') +} + # Helper: determine fillType from cell content function Get-FillType { param($cell) @@ -453,7 +459,7 @@ foreach ($area in $def.areas) { X "`t`t`t`t`t" X "`t`t`t`t`t`t" X "`t`t`t`t`t`t`tru" - X "`t`t`t`t`t`t`t$($cellInfo.Text)" + X "`t`t`t`t`t`t`t$(Esc-Xml $cellInfo.Text)" X "`t`t`t`t`t`t" X "`t`t`t`t`t" } @@ -462,7 +468,7 @@ foreach ($area in $def.areas) { X "`t`t`t`t`t" X "`t`t`t`t`t`t" X "`t`t`t`t`t`t`tru" - X "`t`t`t`t`t`t`t$($cellInfo.Template)" + X "`t`t`t`t`t`t`t$(Esc-Xml $cellInfo.Template)" X "`t`t`t`t`t`t" X "`t`t`t`t`t" }