Commit 8adb60f
committed
fix: validate hex colours in hexColor() to prevent XML injection
hexColor() previously did no validation — just stripped '#' and
uppercased. If a non-hex string (like gradient XML) was passed, it
was silently embedded as an srgbClr val attribute, producing corrupt
OOXML that PowerPoint would repair by stripping entire slides.
Bug reproduction: LLM passes gradient XML or background XML as a
'color' parameter → hexColor uppercases it → solidFill embeds it as
<a:srgbClr val='<P:BG>...'/> → PowerPoint repair strips the slide.
Fix: hexColor() now validates input against /^#?[0-9A-Fa-f]{6}$/
and throws a descriptive error on invalid input, matching the same
regex used by requireHex(). Error message truncates long strings to
avoid dumping XML fragments into the console.
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>1 parent 7ef5d60 commit 8adb60f
3 files changed
Lines changed: 22 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
25 | 36 | | |
26 | 37 | | |
27 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| 57 | + | |
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
| |||
0 commit comments