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): reject descending gradient stops

hugohe38dba124e645f
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.md
index 906c7a55..430688df 100644
--- a/skills/ppt-master/references/shared-standards.md
+++ b/skills/ppt-master/references/shared-standards.md
@@ -744,6 +744,9 @@ round-trip without truncation or percentage reinterpretation. In that non-line
import mapping, each `a:gs` requires an integer `pos` from `0` through `100000`.
Missing, malformed, or out-of-range source positions stop import instead of
being silently relocated to the start of the gradient.
+Source positions must be nondecreasing in document order; equal positions stay
+valid for hard transitions. Descending positions stop import instead of being
+silently clamped by SVG rendering.
An explicit non-line imported `a:gradFill` requires exactly one attribute-free
`a:gsLst` with at least two direct `a:gs` children and no other payload. Every
stop must provide a resolvable color. Missing or duplicate lists, undersized or
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 a574a625..d92a8278 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
@@ -146,9 +146,18 @@ def _resolve_grad_fill(elem: ET.Element, palette: ColorPalette | None,
"DrawingML gradient fill requires exactly one gsLst"
)
gradient_stops = _gradient_stop_list(gs_lists[0])
+ stop_positions = [
+ _gradient_stop_position(gs) for gs in gradient_stops
+ ]
+ if any(
+ current < previous
+ for previous, current in zip(stop_positions, stop_positions[1:])
+ ):
+ raise ValueError(
+ "DrawingML gradient stop positions must be nondecreasing"
+ )
stops_xml = []
- for gs in gradient_stops:
- pos_pct = _gradient_stop_position(gs)
+ for gs, pos_pct in zip(gradient_stops, stop_positions):
color_elem = _gradient_stop_color(gs)
hex_, alpha = resolve_color(
color_elem,
diff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.py
index 2fcb4309..9967ade2 100644
--- a/skills/ppt-master/scripts/test_svg_quality_checker.py
+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py
@@ -2840,6 +2840,40 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):
with self.assertRaisesRegex(ValueError, expected):
resolve_fill(sp_pr, None)
+ def test_native_gradient_stop_positions_must_be_nondecreasing(self):
+ equal_positions = ET.fromstring('''
+<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="50000"><a:srgbClr val="112233"/></a:gs>
+ <a:gs pos="50000"><a:srgbClr val="445566"/></a:gs>
+ </a:gsLst>
+ </a:gradFill>
+</p:spPr>''')
+ fill = resolve_fill(equal_positions, None)
+ gradient = ET.fromstring(fill.defs[0])
+ self.assertEqual(
+ [stop.get('offset') for stop in gradient],
+ ['0.5', '0.5'],
+ )
+
+ descending_positions = ET.fromstring('''
+<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="50000"><a:srgbClr val="112233"/></a:gs>
+ <a:gs pos="40000"><a:srgbClr val="445566"/></a:gs>
+ </a:gsLst>
+ </a:gradFill>
+</p:spPr>''')
+ with self.assertRaisesRegex(
+ ValueError,
+ 'gradient stop positions must be nondecreasing',
+ ):
+ resolve_fill(descending_positions, None)
+
def test_native_gradient_requires_resolvable_stops(self):
invalid_gradients = (
(