fix(email): enforce account ownership and correct partial failure accounting

- Validate account ownership with _assert_owns_account for every account_id
- Deduplicate items in selection to prevent duplicate files and skewed accounting
- Fix exception handling in IMAP batching to avoid double-counting on partial failures
- Re-raise HTTPException so 413 memory cap errors are not swallowed
- Remove unused addField helper in emailLibrary print exporter
- Add behavioral test suite covering empty/oversized validation, rfc822 export,
  zip export, partial failure/dedup, and cross-tenant account isolation
This commit is contained in:
Alexandre Teixeira
2026-10-20 10:35:30 +01:00
parent 8eaf742b43
commit 550ac015eb
3 changed files with 183 additions and 17 deletions
-13
View File
@@ -1143,19 +1143,6 @@ async function _printSelectedEmails(messages) {
};
await Promise.all(Array.from({ length: Math.min(4, messages.length) }, readWorker));
const addField = (doc, parent, label, value) => {
if (!value) return;
const row = doc.createElement('div');
row.className = 'email-export-pdf-field';
const labelEl = doc.createElement('span');
labelEl.className = 'email-export-pdf-label';
labelEl.textContent = label;
const valueEl = doc.createElement('span');
valueEl.textContent = value;
row.append(labelEl, valueEl);
parent.appendChild(row);
};
// Build sanitized HTML for the print frame -- scripts and event handlers
// cannot execute inside the sandboxed iframe.
const articles = [];