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(notes): drop dangling notesMaster rel + add package rels guard

hugohe32a258f51fad3
diff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_builder.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_builder.py
index 63f31649..9bc427cc 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_builder.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_builder.py
@@ -7,6 +7,7 @@ import json
import mimetypes
import os
import re
+import posixpath
import shutil
import tempfile
import zipfile
@@ -292,6 +293,40 @@ def _prerender_legacy_pngs(
return results
+_REL_TARGET_RE = re.compile(r'<Relationship\b[^/]*?/>', re.DOTALL)
+_TARGET_ATTR_RE = re.compile(r'Target="([^"]+)"')
+_TARGET_MODE_EXT_RE = re.compile(r'TargetMode="External"')
+
+
+def _verify_internal_rels_targets(extract_dir: Path) -> list[str]:
+ """Return a list of dangling internal Targets across every .rels in the package.
+
+ Each entry is formatted as "<rels-path> -> <missing-target>". An empty list
+ means every internal Target resolves to a real file in the package.
+ """
+ problems: list[str] = []
+ for rels_path in extract_dir.rglob('*.rels'):
+ rels_rel = rels_path.relative_to(extract_dir).as_posix()
+ # `_rels/foo.xml.rels` lives one level below its referent's directory;
+ # Targets resolve relative to the parent of that `_rels` folder.
+ base_dir = posixpath.dirname(posixpath.dirname(rels_rel))
+ content = rels_path.read_text(encoding='utf-8')
+ for match in _REL_TARGET_RE.finditer(content):
+ element = match.group(0)
+ if _TARGET_MODE_EXT_RE.search(element):
+ continue
+ target_match = _TARGET_ATTR_RE.search(element)
+ if not target_match:
+ continue
+ target = target_match.group(1)
+ if target.startswith(('http://', 'https://', 'mailto:')):
+ continue
+ resolved = posixpath.normpath(posixpath.join(base_dir, target)) if base_dir else posixpath.normpath(target)
+ if not (extract_dir / resolved).exists():
+ problems.append(f'{rels_rel} -> {resolved}')
+ return problems
+
+
def create_pptx_with_native_svg(
svg_files: list[Path],
output_path: Path,
@@ -806,6 +841,14 @@ def create_pptx_with_native_svg(
with open(content_types_path, 'w', encoding='utf-8') as f:
f.write(content_types)
+ rels_problems = _verify_internal_rels_targets(extract_dir)
+ if rels_problems:
+ details = '\n'.join(f' - {p}' for p in rels_problems)
+ raise RuntimeError(
+ 'PPTX package contains dangling internal relationship targets; '
+ 'PowerPoint will report the file as corrupt:\n' + details
+ )
+
# Repackage PPTX to a temporary file first. The public output path is
# replaced only after every slide and relationship has succeeded.
temp_output_path = temp_dir / 'result.pptx'
diff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_notes.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_notes.py
index 563ae84b..2ea29062 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_notes.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_notes.py
@@ -150,8 +150,10 @@ def create_notes_slide_rels_xml(slide_num: int) -> str:
Returns:
Relationship file XML string.
"""
+ # No notesMaster relationship: the base PPTX produced by python-pptx does
+ # not ship a notesMaster part, so referencing one here would create a
+ # dangling rels Target and PowerPoint reports the file as corrupt.
return f'''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
- <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster" Target="../notesMasters/notesMaster1.xml"/>
- <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="../slides/slide{slide_num}.xml"/>
+ <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="../slides/slide{slide_num}.xml"/>
</Relationships>'''