Issue #1121: Fix blank Email options popup when adding an attachment - #1127
Conversation
ETP-4868 The ADD command is submitted to PrintOptions.html, a path matched by neither isPrintPath() nor isSendPath(), so openOptionsPage() returned without writing anything to the response and the popup rendered blank (empty 200 OK). Restore the pre-ETP-4197 if/else shape: print.html renders the print options page, every other path falls back to the email options page. Also drop the now unused isSendPath() helper, correct an unclosed <th> and a malformed value attribute in the Attached Documents block of EmailOptions.html, and replace the test that asserted the no-op behaviour with regression coverage for the PrintOptions.html path.
| // PrintOptions.html when the popup itself posts back (ADD command). This must stay a fallback | ||
| // branch instead of a second condition, otherwise an unmatched path silently writes nothing to | ||
| // the response and the popup renders blank. | ||
| controller.createEmailOptionsPage(request, response, vars, context.documentType, docIdsForPage, |
ETP-4868 createEmailOptionsPage built the pocData session key with normalizeDocumentId, which only strips parentheses and quotes, while PrintControllerCommandHandler reads that same key back using sanitizeDocumentIdentifier. Any character outside the allowlist made the write and read sides diverge. Use the same sanitizer on both sides, which also closes the SnykCode trust-boundary flow into VariablesBase.setSessionObject.
|
SnykCode alert 3828 (
|

0 New Issues
0 Fixed Issues
0 Accepted Issues
Fixes #1121 — ETP-4868
Root cause
PrintInvoices(and every other print controller) is mapped to three URLs:/invoices/send.html,/invoices/print.htmland/invoices/PrintOptions.html. The Email options popup is opened throughsend.html, but its own form posts back toPrintOptions.html:So the
ADDcommand issued by "Add Attachment" arrives onPrintOptions.html, whereopenOptionsPage()matched neither branch:isPrintPath()→false, because the literal substringprint.htmlis not contained inprintoptions.html(the characters afterprintareoptions, not.html)isSendPath()→false, nosend.htmlsubstringThe method returned without writing anything to the response, producing the empty
200 OKand the blank popup. No exception anywhere, because it was a silent no-op rather than a failure.This is a regression from the ETP-4197 refactor (#1049, released in 26.1.10). Before it, the
ADDcommand inPrintController.post()was anif/elsewith a fallback:The refactor turned that into two independent
ifs with no fallback.Fix
Restore the
if/elseshape inPrintControllerCommandHandler.openOptionsPage():print.htmlrenders the print options page, every other path falls back to the email options page. This was preferred over addingisPrintOptionsPath()as a third condition because it removes the whole class of failure — an unmatched path can no longer leave the response empty — and it matches the pre-regression behaviour exactly.isSendPath()becomes unused and is removed (isPrintOptionsPath()stays, it is still used byvalidateSenderConfiguration()).Tests
PrintControllerCommandHandlerTesthad encoded the bug:testHandle_addCommand_otherPath_callsNeither()asserted that neither page builder was called. That expectation was replaced with correct coverage:testHandle_addCommand_printOptionsPath_callsCreateEmailOptionsPage— the exact regressiontestHandle_addCommand_printOptionsPath_salesOrder_callsCreateEmailOptionsPage— the handler is shared across document typestestHandle_addCommand_otherPath_fallsBackToEmailOptionsPage— the response is never left emptytestIsPrintPath_printOptionsHtml_returnsFalse— documents the substring trap that caused thisThe three new
ADDtests fail against the pre-fix code and pass with it. The wholereporting.printingtest package (13 classes, 181 tests) passes.Manual verification
Verified on a local 26.2.7 instance whose core sources were confirmed byte-for-byte identical to
mainbefore patching:print.htmlpath) still renders correctly — no regression on that branch.Also included
Two malformed-markup fixes in the "Attached Documents" block of
EmailOptions.html: an unclosed<th>and avalue="""attribute. The deprecatedwidthattribute on the same line was converted to an inline style so the change does not introduce a new Web-analyzer violation on a modified line.Deliberately not touched: the unbalanced
div/tr/tdnesting around the same block. Those<div id="sectionDetail">/<div id="sectionDetail2">elements are declared as<SECTION>inEmailOptions.xml, so they are XmlEngine section markers and their boundaries define which markup repeats per row. Rebalancing them would change repetition semantics, not just formatting — it belongs in its own change with its own validation.