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(svg_to_pptx): resolve URL-encoded image hrefs

hugohe3a823a25ad0b1
diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py
index 7fcb9765..147db02a 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py
@@ -8,7 +8,7 @@ import re
import base64
from pathlib import Path
from typing import Any
-from urllib.parse import unquote_to_bytes
+from urllib.parse import unquote, unquote_to_bytes, urlsplit
from xml.etree import ElementTree as ET
from .drawingml_context import ConvertContext, ShapeResult
@@ -43,11 +43,16 @@ def _resolve_external_image(svg_dir: Path, href: str) -> Path:
(legacy flat-copied template assets). Raises ``FileNotFoundError`` if none
of these exist.
"""
+ parsed = urlsplit(href)
+ if parsed.scheme and parsed.scheme not in ('file',):
+ raise FileNotFoundError(f'External image not found: {href}')
+ decoded = unquote(parsed.path if parsed.scheme else href.split('?', 1)[0].split('#', 1)[0])
+
for candidate in (
- svg_dir / href,
- svg_dir.parent / href,
- svg_dir.parent / 'images' / href,
- svg_dir.parent / 'templates' / href,
+ svg_dir / decoded,
+ svg_dir.parent / decoded,
+ svg_dir.parent / 'images' / decoded,
+ svg_dir.parent / 'templates' / decoded,
):
if candidate.exists():
return candidate