Bug 51187 - Opening and saving PPTX with specific image corrupts file (Power point will no longer open)
Summary: Opening and saving PPTX with specific image corrupts file (Power point will n...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSLF (show other bugs)
Version: 3.8-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-11 23:09 UTC by Trey Hyde
Modified: 2011-08-11 08:13 UTC (History)
0 users



Attachments
File that will be corrupted if you open and save it. (44.61 KB, application/vnd.openxmlformats-officedocument.presentationml.presentation)
2011-05-11 23:09 UTC, Trey Hyde
Details
End result of open/close (40.63 KB, application/vnd.openxmlformats-officedocument.presentationml.presentation)
2011-05-11 23:10 UTC, Trey Hyde
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Trey Hyde 2011-05-11 23:09:27 UTC
Created attachment 26986 [details]
File that will be corrupted if you open and save it.

Executing this code against the attached file will create a file that is unreadable PPT.  The PPT contains only a single small image.

  OPCPackage docPackage = OPCPackage.openOrCreate(input);

File output = File.createTempFile("office-ooxml-",null);
            System.out.println(output.getCanonicalPath());
            docPackage.save(output);


Same was true for 3.7 vs 3.8-beta2

In ppt/slides/_rels/slide1.xml.rels I notedd that the target on rId3 went from slide1.xml on the good version to "" on the bad.   Could be more material differences, I just didn't notice.
Comment 1 Trey Hyde 2011-05-11 23:10:23 UTC
Created attachment 26987 [details]
End result of open/close
Comment 2 Trey Hyde 2011-05-11 23:11:54 UTC
Same code scenario as ticket #50154 btw
Comment 3 Nick Burch 2011-05-27 14:36:16 UTC
This looks to be an issue with self references during the save step

I've added a unit test in r1128324 which shows the problem. Someone'll need to dig into the OPC code to try to spot what's going wrong
Comment 4 Yegor Kozlov 2011-08-11 08:13:40 UTC
Fixed in r1156529

Nick is right, it was an issue with saving self references. PackagingURIHelper#relativizeURI resolved self references to an empty string which is wrong. The correct behavior is to return the last segment in the URI. In your case both the source and target URIs are /ppt/slides/slide1.xml and the value written in the relationship part should be slide1.xml (was empty string). 

It appears that self-referencing is legal from the OPC point of view. One way to reproduce the problem in MS Office is to create a .pptx presentation, add a slide and put a hyperlink that points to this slide. The slide will reference itself in /slides/_rels/slide1.xml.rels.  

Yegor