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 path gradient structure

hugohe3dc9569294bd4
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.md
index 6423e134..6ebf21ec 100644
--- a/skills/ppt-master/references/shared-standards.md
+++ b/skills/ppt-master/references/shared-standards.md
@@ -768,6 +768,9 @@ For the registered path-gradient approximation, omitted `a:path@path` uses the
schema default `rect`; explicit `circle`, `rect`, and `shape` are normalized to
the centered radial SVG form. Unknown or malformed enum values stop import
instead of being mislabeled as a supported radial gradient.
+The imported `a:path` permits only its optional `path` attribute and zero or one
+direct `a:fillToRect` child. Extra or namespaced attributes, foreign children,
+and interleaved text payload stop import instead of being discarded.
The local SVG gradient rotates with its containing geometry. Imported
`a:gradFill@rotWithShape` may therefore be omitted for the documented Office
base default or be the exact XML booleans `1` / `true`. Explicit `0` / `false`
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 d055c62f..5dd2bd0e 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
@@ -193,6 +193,7 @@ def _resolve_grad_fill(elem: ET.Element, palette: ColorPalette | None,
+ "</linearGradient>"
)
elif rad is not None:
+ _validate_path_gradient_structure(rad)
_validate_path_gradient_type(rad)
_validate_path_gradient_focus(rad)
# Treat as radial regardless of path="circle" / "rect" / "shape" — SVG
@@ -404,6 +405,25 @@ def _validate_path_gradient_type(path: ET.Element) -> None:
)
+def _validate_path_gradient_structure(path: ET.Element) -> None:
+ """Require only the registered path attribute and focus rectangle."""
+ unsupported = sorted(set(path.attrib) - {"path"})
+ children = list(path)
+ fill_to_rect_tag = f"{{{NS['a']}}}fillToRect"
+ has_invalid_payload = (
+ (path.text or "").strip()
+ or any(
+ child.tag != fill_to_rect_tag or (child.tail or "").strip()
+ for child in children
+ )
+ )
+ if unsupported or has_invalid_payload:
+ details = ", ".join(unsupported) if unsupported else "payload"
+ raise ValueError(
+ f"Invalid DrawingML path gradient structure: {details}"
+ )
+
+
def _resolve_blip_fill(_elem, _palette, _prefix, _seq, _placeholder_hex) -> FillResult:
"""blipFill on <p:spPr> means a shape filled with an image — handled at
pic_to_svg level. For now mark as transparent so the shape's outline
diff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.py
index 99dc43d1..f2e74ad3 100644
--- a/skills/ppt-master/scripts/test_svg_quality_checker.py
+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py
@@ -3065,6 +3065,33 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):
):
resolve_path(path_type)
+ def test_native_path_gradient_structure_must_be_closed(self):
+ invalid_path_directions = (
+ '<a:path path="circle" future="x"/>',
+ '<a:path xmlns:future="urn:future" path="circle" '
+ 'future:mode="x"/>',
+ '<a:path path="circle"><a:ext/></a:path>',
+ '<a:path path="circle">payload</a:path>',
+ '<a:path path="circle"><a:fillToRect/>payload</a:path>',
+ )
+ for path_direction in invalid_path_directions:
+ with self.subTest(path_direction=path_direction):
+ 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>
+ <a:gsLst>
+ <a:gs pos="0"><a:srgbClr val="112233"/></a:gs>
+ </a:gsLst>
+ {path_direction}
+ </a:gradFill>
+</p:spPr>''')
+ with self.assertRaisesRegex(
+ ValueError,
+ 'Invalid DrawingML path gradient structure',
+ ):
+ resolve_fill(sp_pr, None)
+
def test_native_gradient_must_rotate_with_shape(self):
def resolve_rotation(rotates: str | None):
rotation_attr = (