Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Replace relations in documents #119

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class OOXMLBleach implements Bleach {
private static final String DUMMY_FILE_CONTENT = "BLEACHED";
private static final PackagePartName DUMMY_PACKAGE_PART_NAME =
createPartName(DUMMY_FILE_PART_NAME);
private static final String DUMMY_WEB_ADDRESS = "https://127.0.0.1/";

private static final String[] WHITELISTED_RELATIONS =
new String[]{
Expand Down Expand Up @@ -351,10 +352,13 @@ private void sanitize(
*/
private void replaceRelationship(RelationshipSource pkg, PackageRelationship relationship) {
String rId = relationship.getId();

String rRT = relationship.getRelationshipType();
pkg.removeRelationship(rId);
pkg.addRelationship(
DUMMY_PACKAGE_PART_NAME, TargetMode.INTERNAL, Relations.OPENXML_OLE_OBJECT, rId);
if (relationship.getTargetMode() == TargetMode.EXTERNAL){
pkg.addExternalRelationship(DUMMY_WEB_ADDRESS, rRT, rId);
} else {
pkg.addRelationship(DUMMY_PACKAGE_PART_NAME, TargetMode.INTERNAL, rRT, rId);
}
}

private boolean isBlacklistedRelationType(String relationshipType) {
Expand Down