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): validate custom dash stops
hugohe35b454f2ccb8d
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.mdindex f8697695..254886fb 100644--- a/skills/ppt-master/references/shared-standards.md+++ b/skills/ppt-master/references/shared-standards.md@@ -998,6 +998,10 @@ back to the SVG default cap.PPTX import maps only the registered DrawingML `prstDash` values; `solid`remains an intentional line with no SVG dash array, while an unknown sourcevalue stops import instead of being mistaken for `solid`.+An imported `a:custDash` contains one or more direct, empty `a:ds` children;+each stop has exactly `d` and `sp`, both positive OOXML integers. Missing or+extra fields, foreign children, malformed numbers, and values outside the+positive 32-bit integer range stop import instead of being skipped.The dash grammar is closed: exact lowercase `none`, or at least two finiteunitless numbers separated by whitespace or one comma. Generated SVG usesdiff --git a/skills/ppt-master/scripts/pptx_to_svg/ln_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/ln_to_svg.pyindex 28c7e659..89a719bd 100644--- a/skills/ppt-master/scripts/pptx_to_svg/ln_to_svg.py+++ b/skills/ppt-master/scripts/pptx_to_svg/ln_to_svg.py@@ -40,6 +40,7 @@ PRST_DASH_TO_ARRAY = {"sysDashDot": "3 3 1 3","sysDashDotDot": "3 3 1 3 1 3",}+_OOXML_INT_MAX = 2**31 - 1# DrawingML cap -> SVG stroke-linecapCAP_MAP = {@@ -138,17 +139,38 @@ def resolve_stroke(if cust_dash is not None:ds_parts: list[str] = []sw = float(attrs.get("stroke-width", "1") or "1") or 1.0- for ds in cust_dash.findall("a:ds", NS):+ dash_stops = list(cust_dash)+ expected_tag = f"{{{NS['a']}}}ds"+ if not dash_stops or any(+ ds.tag != expected_tag+ or set(ds.attrib) != {"d", "sp"}+ or list(ds)+ for ds in dash_stops+ ):+ raise ValueError("Invalid DrawingML custom dash structure")+ for ds in dash_stops:# d, sp are percentages of stroke width (1000ths)- try:- d_pct = int(ds.attrib.get("d", "0"))- sp_pct = int(ds.attrib.get("sp", "0"))- except ValueError:- continue+ values: dict[str, int] = {}+ for name in ("d", "sp"):+ raw_value = ds.attrib[name]+ try:+ value = int(raw_value)+ except (ValueError, TypeError):+ raise ValueError(+ f"Invalid DrawingML custom dash {name}: "+ f"{raw_value!r}"+ ) from None+ if not 0 < value <= _OOXML_INT_MAX:+ raise ValueError(+ f"DrawingML custom dash {name}={value} is "+ "outside the positive OOXML integer range"+ )+ values[name] = value+ d_pct = values["d"]+ sp_pct = values["sp"]ds_parts.append(fmt_num(d_pct / 100000.0 * sw, 2))ds_parts.append(fmt_num(sp_pct / 100000.0 * sw, 2))- if ds_parts:- attrs["stroke-dasharray"] = " ".join(ds_parts)+ attrs["stroke-dasharray"] = " ".join(ds_parts)# Joinif ln.find("a:round", NS) is not None:diff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.pyindex 6e3ece4b..cbf6e6e2 100644--- a/skills/ppt-master/scripts/test_svg_quality_checker.py+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py@@ -2689,6 +2689,46 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):):resolve_stroke(sp_pr, None)+ def test_invalid_native_custom_dash_is_rejected_on_import(self):+ cases = (+ ('', 'Invalid DrawingML custom dash structure'),+ (+ '<a:ds d="bad" sp="100000"/>',+ "Invalid DrawingML custom dash d: 'bad'",+ ),+ (+ '<a:ds d="100000" sp="0"/>',+ 'DrawingML custom dash sp=0 is outside',+ ),+ (+ '<a:ds d="100000" sp="100000" extra="1"/>',+ 'Invalid DrawingML custom dash structure',+ ),+ )+ for dash_stops, expected in cases:+ with self.subTest(dash_stops=dash_stops):+ 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:ln><a:custDash>{dash_stops}</a:custDash></a:ln>+</p:spPr>''')+ with self.assertRaisesRegex(ValueError, expected):+ resolve_stroke(sp_pr, None)++ def test_native_custom_dash_preserves_all_stops_on_import(self):+ sp_pr = ET.fromstring('''+<p:spPr xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"+ xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">+ <a:ln w="9525">+ <a:custDash>+ <a:ds d="100000" sp="200000"/>+ <a:ds d="300000" sp="400000"/>+ </a:custDash>+ </a:ln>+</p:spPr>''')+ stroke = resolve_stroke(sp_pr, None)+ self.assertEqual(stroke.attrs['stroke-dasharray'], '1 2 3 4')+def test_imported_head_end_uses_supported_reversible_orientation(self):drawingml_ns = ('http://schemas.openxmlformats.org/drawingml/2006/main'