Skip to content

Commit 9659f49

Browse files
toaditiclaude
andauthored
Fixed: Order view page CSS leak from embedded email communication content (OFBIZ-13390) (#1213)
## Summary When a `CommunicationEvent` exists on an order, the `OrderConversations` screen dumps the stored email HTML (a full `<!DOCTYPE html>` document, with its own `<style>` block containing a global CSS reset) directly inline into the order view page. Browsers parse that `<style>` at document scope — not div scope — so the email's reset cascades into the parent page and breaks the order layout: tables lose padding, the body background changes, `.screenlet` styling is overridden, etc. ## Fix Render the email body inside an `<iframe>` so its CSS lives in its own document context and cannot leak. The stored content is HTML-entity-encoded, so it's decoded client-side via a `<textarea>` before being assigned to `srcdoc`. One file changed: `applications/party/template/party/DisplayCommunicationContent.ftl`. ## Test plan - [ ] Open an order that has at least one communication event (e.g. send an order confirmation email, then revisit the order view). - [ ] Expand the "All Communication Events" section. - [ ] Verify the email body renders inside a bordered iframe with the email's own styling (heading, cards, items table). - [ ] Verify the parent order view page styling is unaffected — tables, padding, screenlets all render normally. - [ ] Verify the iframe auto-resizes to fit the email content (`onload` handler). Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 355d3d4 commit 9659f49

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

applications/party/template/party/DisplayCommunicationContent.ftl

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,22 @@ under the License.
1818
-->
1919

2020

21-
<#-- Display content in a specific div to avoid display conflicts -->
22-
<div style="margin-left: 14%;width:50% !important;">
23-
${StringUtil.wrapString(childCommEvent.content!)}
24-
</div>
21+
<#-- iframe isolates the email's <style> block from the parent page. Stored content is
22+
HTML-entity-encoded, so decode it via a textarea before assigning to srcdoc. -->
23+
<#assign iframeId = "commContent_" + childCommEvent.communicationEventId>
24+
<iframe id="${iframeId}"
25+
sandbox="allow-same-origin"
26+
style="width: 100%; min-height: 600px; border: 1px solid #ccc; margin-left: 14%;"></iframe>
27+
<script type="text/javascript">
28+
(function() {
29+
var iframe = document.getElementById('${iframeId}');
30+
iframe.onload = function() {
31+
try {
32+
this.style.height = (this.contentWindow.document.documentElement.scrollHeight + 20) + 'px';
33+
} catch (e) {}
34+
};
35+
var decoder = document.createElement('textarea');
36+
decoder.innerHTML = '${StringUtil.wrapString((childCommEvent.content!'')?js_string)}';
37+
iframe.srcdoc = decoder.value;
38+
})();
39+
</script>

0 commit comments

Comments
 (0)