Skip to content

AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He

fix(pptx-to-svg): close gradient fill child structure

hugohe3fff544e41788
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.md
index 430688df..0904e875 100644
--- a/skills/ppt-master/references/shared-standards.md
+++ b/skills/ppt-master/references/shared-standards.md
@@ -756,6 +756,10 @@ Each imported `a:gs` has exactly the required `pos` attribute and exactly one
direct registered DrawingML color child, with no interleaved text. Extra or
namespaced attributes, missing/multiple/foreign color children, and text payload
stop import instead of being reduced to the first recognizable color.
+The direct children of an imported non-line `a:gradFill` follow the closed
+DrawingML sequence `a:gsLst`, optional `a:lin` or `a:path`, then optional
+`a:tileRect`, with no text payload. Unknown children, foreign-namespace aliases,
+and out-of-order registered children stop import instead of being ignored.
An imported non-line `a:lin@ang` may be omitted for the schema-defined zero
default. When present, it must be an integer from `0` through `21599999`
(1/60000 degree); malformed or out-of-range values stop import instead of
diff --git a/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py
index d92a8278..8167f85b 100644
--- a/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py
+++ b/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py
@@ -185,6 +185,7 @@ def _resolve_grad_fill(elem: ET.Element, palette: ColorPalette | None,
"DrawingML gradient fill must contain at most one lin/path "
"direction"
)
+ _validate_gradient_child_structure(elem)
lin = linear_directions[0] if linear_directions else None
rad = path_directions[0] if path_directions else None
@@ -350,6 +351,32 @@ def _validate_gradient_attributes(gradient: ET.Element) -> None:
)
+def _validate_gradient_child_structure(gradient: ET.Element) -> None:
+ """Require the registered DrawingML gradient-fill child sequence."""
+ namespace = NS["a"]
+ gs_list = f"{{{namespace}}}gsLst"
+ linear = f"{{{namespace}}}lin"
+ path = f"{{{namespace}}}path"
+ tile_rect = f"{{{namespace}}}tileRect"
+ child_tags = tuple(child.tag for child in gradient)
+ allowed_sequences = {
+ (gs_list,),
+ (gs_list, linear),
+ (gs_list, path),
+ (gs_list, tile_rect),
+ (gs_list, linear, tile_rect),
+ (gs_list, path, tile_rect),
+ }
+ if (
+ child_tags not in allowed_sequences
+ or (gradient.text or "").strip()
+ or any((child.tail or "").strip() for child in gradient)
+ ):
+ raise ValueError(
+ "Invalid DrawingML gradient fill child structure"
+ )
+
+
def _validate_gradient_flip(gradient: ET.Element) -> None:
"""Reject gradient tile flipping absent from project SVG."""
flip = gradient.get("flip", "none")
diff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.py
index 9967ade2..8e4cf10f 100644
--- a/skills/ppt-master/scripts/test_svg_quality_checker.py
+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py
@@ -2968,6 +2968,34 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):
):
resolve_fill(sp_pr, None)
+ def test_native_gradient_fill_child_structure_must_be_closed(self):
+ stop_list = (
+ '<a:gsLst>'
+ '<a:gs pos="0"><a:srgbClr val="112233"/></a:gs>'
+ '<a:gs pos="100000"><a:srgbClr val="445566"/></a:gs>'
+ '</a:gsLst>'
+ )
+ invalid_children = (
+ f'{stop_list}<a:future/>',
+ f'{stop_list}<future:lin xmlns:future="urn:future"/>',
+ f'<a:lin/>{stop_list}',
+ f'{stop_list}<a:tileRect/><a:lin/>',
+ f'payload{stop_list}',
+ f'{stop_list}payload',
+ )
+ for children in invalid_children:
+ with self.subTest(children=children):
+ sp_pr = ET.fromstring(f'''
+<p:spPr xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"
+ xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
+ <a:gradFill>{children}</a:gradFill>
+</p:spPr>''')
+ with self.assertRaisesRegex(
+ ValueError,
+ 'Invalid DrawingML gradient fill child structure',
+ ):
+ resolve_fill(sp_pr, None)
+
def test_native_linear_gradient_angle_must_be_valid(self):
valid_angles = (
(None, None, 0.0),