fix(makeXmlContTypes): correct jpg MIME + drop ghost slideMaster Overrides (closes #1444)#1462
Open
IgnasStark wants to merge 1 commit into
Open
Conversation
…rides
Two long-standing bugs in [Content_Types].xml generation, both inside
makeXmlContTypes() at src/gen-xml.ts:
1. `image/jpg` is not an IANA-registered MIME — the valid type is
`image/jpeg`. PPT files generated with `image/jpg` open in lenient
parsers but trigger strict-mode warnings (e.g. SoftMaker FreeOffice,
some OOXML linters). Extension stays `jpg` (the binary on disk is
still .jpg); only the ContentType changes.
2. The slides.forEach loop emits one `<Override>` per slide pointing at
`/ppt/slideMasters/slideMaster${idx+1}.xml`, but PptxGenJS only ever
serializes slideMaster1.xml to the zip. Result: an N-slide deck has
N-1 ghost slideMaster Overrides declared in [Content_Types].xml with
no corresponding part on disk. Fix: hoist a single literal
slideMaster1.xml Override above the loop; drop the per-slide
templated line.
Closes gitbrent#1444.
The two changes are independent but share the same two-line area of the
function; combining them in one PR keeps the diff small and the review
focused.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two long-standing bugs in
[Content_Types].xmlgeneration, both insidemakeXmlContTypes()atsrc/gen-xml.ts. Both fixed in one PR because they share the same two-line region of the function and are mechanically tiny.Bug 1 —
image/jpgis not an IANA-registered MIMEimage/jpgdoes not exist in the IANA registry — the valid type isimage/jpeg. PPT files generated withimage/jpgopen in lenient parsers (PowerPoint Desktop, Keynote, LibreOffice, Google Slides) but trigger strict-mode warnings in OOXML linters and some compliance-focused parsers (e.g. SoftMaker FreeOffice). The file extension on the binary stays.jpg; only the MIME changes.Bug 2 — ghost slideMaster Overrides (closes #1444)
The
slides.forEachloop currently emits one<Override PartName="/ppt/slideMasters/slideMaster${idx + 1}.xml"/>per slide, but PptxGenJS only ever serializes a singleslideMaster1.xmlto the zip (seegenMasterSlide()which writes one master regardless of slide count). Result: an N-slide deck declares N slideMaster Overrides in[Content_Types].xmlbut onlyslideMaster1.xmlexists on disk — N-1 ghost references.PowerPoint Desktop tolerates this and silently ignores the ghosts. Stricter parsers report orphan Overrides; some online viewers (and PowerPoint Repair if the file is round-tripped) flag the file as corrupt and rewrite it.
The fix is structural: hoist a single literal
slideMaster1.xmlOverride above theslides.forEachand drop the per-slide templated line. The forEach still iterates forslides/slide${idx+1}.xmlOverrides and chart Overrides — only the slideMaster line is hoisted out.Tracked at issue #1444 (open Feb 2026).
Verification
Generated a 2-slide deck with this branch applied, inspected
[Content_Types].xml:slideMaster<N>.xmlOverride count for 2-slide deckExtension="jpg" ContentType="image/jpg"Extension="jpg" ContentType="image/jpeg"slide<N>.xmlOverride countNo behaviour change for lenient parsers; strict-mode warnings cleared.
Context
Downstream consumer (Skaylink Presentation Generator) is shipping this exact patch via
patch-packageagainstpptxgenjs@4.0.1because the upstream issue has been open since Feb 2026 without movement. Filing this PR as the courtesy upstream contribution so future versions don't need the patch.