Document: "Insert Spreadsheet" (embedded spreadsheet object) is silently dropped on Save & Exit
Description
In the Document app, Insert → Table → Insert Spreadsheet opens the spreadsheet editor, but clicking "Save & Exit" inserts nothing into the document. No error is shown.
The cause is the imgurls handler in www/common/onlyoffice/inner.js, which answers OnlyOffice's request for the object's preview image (a data:image/png URL) in two ways that fail:
- It calls
Util.fetch()on thedata:URL. The sandbox CSP (connect-src 'self' blob: <main> <sandbox> …, fromlib/defaults.jsand the example nginx config) does not allowdata:, so the fetch is blocked and the error is swallowed (if (err) { return; }). - Even when the fetch succeeds (tested by adding
data:toconnect-src), the handler pushes a bareURL.createObjectURL(blob)string intourls. The other branch pushes{path, url}objects, and OnlyOffice'saddTableOleObject/editTableOleObjectrequire that shape:if (data[0] && data[0].path != null && data[0].url !== "error"). So the object is still dropped silently. - After fixing the shape, a
blob:URL created in the outer frame (main origin) can't be loaded by the editor running on the sandbox origin (CSPdefault-srcblock onblob:<main-origin>/…). The preview stays blank until the page is reloaded.
Reproduced on a production deployment (separate HTTPS main and sandbox domains, official Docker image cryptpad/cryptpad:version-2026.5.1, OnlyOffice v9 installed with CPAD_INSTALL_ONLYOFFICE=yes) and on a local instance. It is not specific to localhost or HTTP.
Steps to reproduce
- Create a new Document (OnlyOffice-based).
- Insert → Table → Insert Spreadsheet.
- Enter a few values (e.g. 20, 10, 2 in A1:A3) and a formula (
=SUM(A1:A3)). - Click "Save & Exit".
Relevant logs
Content-Security-Policy: The page's settings blocked the loading of a resource (connect-src) at data:image/png;base64,iVBORw0KGgoAAAANSU… because it violates the following directive: "connect-src 'self' blob: <main-origin> <sandbox-origin> <ws-origin>" common-util.js:473:17Expected behavior
The spreadsheet object is inserted into the document at the cursor, shows its visible range, and can be edited again by double-clicking, as in OnlyOffice Docs.
Suggested fix (tested)
Reply with the data: URL itself, in the {path, url} shape OnlyOffice expects. That avoids both the blocked fetch and the cross-origin blob URL. img-src already allows data:. The change applies to both imgurls handlers in inner.js:
if (/^data\:image/.test(name)) {
- Util.fetch(name, waitFor(function (err, u8) {
- if (err) { return; }
- var b = new Blob([u8]);
- urls.push(URL.createObjectURL(b));
- }));
+ urls.push({ path: name, url: name });
return;
}With this change, the embedded spreadsheet is inserted and rendered immediately, and it is still there after a reload. We have not assessed whether you would prefer to store the preview as an encrypted blob, as for uploaded images.
Which operating system are you using?
Linux/BSD/UNIX (Linux Mint), Microsoft Windows (Windows Server 2022)
What browsers are you seeing the problem on?
Mozilla Firefox
Extensions
Reproduced both with one content-script extension installed and in a browser profile with no extensions.
Version
2026.5.1
Source: cryptpad/cryptpad