Skip to content

Commit 4765c3e

Browse files
authored
Merge pull request #151 from mendix/run/fix-4540-4543
Fixes for RUN-4540 and RUN-4543
2 parents 09d9aa8 + 3192764 commit 4765c3e

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Added null check and close open streams.
2+
0 Bytes
Binary file not shown.

src/CommunityCommons/javasource/communitycommons/Misc.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -674,18 +674,19 @@ public static boolean overlayPdf(IContext context, IMendixObject generatedDocume
674674
Logging.trace(LOGNODE, "Overlay PDF start, retrieve overlay PDF");
675675

676676
Logging.trace(LOGNODE, "Perform overlay");
677-
Overlay overlay = new Overlay();
678-
overlay.setInputPDF(inputDoc);
679-
overlay.setDefaultOverlayPDF(overlayDoc);
680-
if (onTopOfContent == true) {
681-
overlay.setOverlayPosition(Overlay.Position.FOREGROUND);
682-
} else {
683-
overlay.setOverlayPosition(Overlay.Position.BACKGROUND);
684-
}
677+
try (Overlay overlay = new Overlay()) {
678+
overlay.setInputPDF(inputDoc);
679+
overlay.setDefaultOverlayPDF(overlayDoc);
680+
if (onTopOfContent) {
681+
overlay.setOverlayPosition(Overlay.Position.FOREGROUND);
682+
} else {
683+
overlay.setOverlayPosition(Overlay.Position.BACKGROUND);
684+
}
685685

686-
Logging.trace(LOGNODE, "Save result in output stream");
686+
Logging.trace(LOGNODE, "Save result in output stream");
687687

688-
overlay.overlay(new HashMap<>()).save(baos);
688+
overlay.overlay(new HashMap<>()).save(baos);
689+
}
689690

690691
Logging.trace(LOGNODE, "Duplicate result in input stream");
691692
try (InputStream overlayedContent = new ByteArrayInputStream(baos.toByteArray())) {

src/CommunityCommons/javasource/communitycommons/StringUtils.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,12 @@ public static String sanitizeHTML(String html, List<SanitizerPolicy> policyParam
493493
PolicyFactory policyFactory = null;
494494

495495
for (SanitizerPolicy param : policyParams) {
496-
policyFactory = (policyFactory == null) ? SANITIZER_POLICIES.get(param.name()) : policyFactory.and(SANITIZER_POLICIES.get(param.name()));
496+
PolicyFactory policyFactoryForParam = SANITIZER_POLICIES.get(param.name());
497+
policyFactory = (policyFactory == null) ? policyFactoryForParam : policyFactory.and(policyFactoryForParam);
498+
}
499+
500+
if (policyFactory == null) {
501+
throw new IllegalArgumentException("Sanitizer policy not found.");
497502
}
498503

499504
return sanitizeHTML(html, policyFactory);

0 commit comments

Comments
 (0)