Pptxgenjs: [BUG] addSection does not escape XML unsafe characters

Created on 20 Jun 2020  路  3Comments  路  Source: gitbrent/PptxGenJS

Category

  • [ ] Enhancement
  • [X] Bug
  • [ ] Question
  • [ ] Documentation gap/issue

Version

Please specify what version of the library you are using: [ 3.2.1 ]

Please specify what version(s) of PowerPoint you are targeting: [ PowerPOint for Mac 16.16.23 (200615) ]

Steps to Reproduce

const title = "A < B";
ppt.addSection({ title });
ppt.addSlide({ sectionTitle: title })

Expected / Desired Behavior / Question

Slide appears section with title "A < B"

Observed Behavior

Output pptx file fails to open in PowerPoint:

PowerPoint found a problem with content in example.pptx

Examining the XML shows that title is used without escaping:

<p14:section name="A < B" id="...">

The title should be escaped to prevent XML parsing errors.

Workaround

Do the escaping yourself:

const title = "A &lt; B"
bug

All 3 comments

Having sections in our long deck is very nice, but got caught by this bug today and ended up losing a few hours before figuring out what had happened.

Thanks @pimlottc-gov

Sorry for the wasted hours - I should have had a test case for this.

Fixed in master, target v3.3.0

Screen Shot 2020-06-22 at 21 48 31

@gitbrent it's my fault for pushing code with multiple changes, got mislead as to what the real issue was. Unfortunately for all of us, PowerPoint is not very verbose about parsing errors.

Thanks for getting the fix in quickly!

Was this page helpful?
0 / 5 - 0 ratings