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

hugohe3ed7f15533b68
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.md
index c7460b3c..6423e134 100644
--- a/skills/ppt-master/references/shared-standards.md
+++ b/skills/ppt-master/references/shared-standards.md
@@ -752,6 +752,9 @@ 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
silently becoming a horizontal gradient.
+The imported `a:lin` is a leaf with only optional `ang` and `scaled`
+attributes. Extra or namespaced attributes, child elements, and text payload
+stop import instead of being discarded.
The normalized SVG endpoint mapping preserves `a:lin@scaled="1"` / `"true"`
at every angle. The schema default (`scaled` omitted) and explicit `"0"` /
`"false"` are accepted only at cardinal angles, where aspect-ratio scaling
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 83b09c60..d055c62f 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
@@ -180,6 +180,7 @@ def _resolve_grad_fill(elem: ET.Element, palette: ColorPalette | None,
if lin is not None:
# ang is 1/60000 deg. 0° = horizontal left-to-right.
+ _validate_linear_gradient_structure(lin)
angle = _linear_gradient_angle(lin)
_validate_linear_gradient_scaling(lin, angle)
angle_deg = angle / ANGLE_UNIT
@@ -251,6 +252,16 @@ def _linear_gradient_angle(lin: ET.Element) -> int:
return angle
+def _validate_linear_gradient_structure(lin: ET.Element) -> None:
+ """Require one leaf a:lin with only the registered attributes."""
+ unsupported = sorted(set(lin.attrib) - {"ang", "scaled"})
+ if unsupported or list(lin) or (lin.text or "").strip():
+ details = ", ".join(unsupported) if unsupported else "payload"
+ raise ValueError(
+ f"Invalid DrawingML linear gradient structure: {details}"
+ )
+
+
def _validate_linear_gradient_scaling(
lin: ET.Element,
angle: int,
diff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.py
index 234dbfba..99dc43d1 100644
--- a/skills/ppt-master/scripts/test_svg_quality_checker.py
+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py
@@ -2968,6 +2968,31 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):
):
resolve_linear('0', scaled)
+ def test_native_linear_gradient_structure_must_be_closed(self):
+ invalid_linear_directions = (
+ '<a:lin ang="0" future="x"/>',
+ '<a:lin xmlns:future="urn:future" ang="0" future:mode="x"/>',
+ '<a:lin ang="0"><a:ext/></a:lin>',
+ '<a:lin ang="0">payload</a:lin>',
+ )
+ for linear_direction in invalid_linear_directions:
+ with self.subTest(linear_direction=linear_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>
+ {linear_direction}
+ </a:gradFill>
+</p:spPr>''')
+ with self.assertRaisesRegex(
+ ValueError,
+ 'Invalid DrawingML linear gradient structure',
+ ):
+ resolve_fill(sp_pr, None)
+
def test_native_gradient_direction_must_be_unambiguous(self):
direction_cases = (
'<a:lin ang="0"/><a:lin ang="0"/>',