Repository navigation
fix(federation): post messages to the initiator origin from the remote page - #6190
Merged
ArtificialOwl merged 1 commit intoOct 20, 2026
Merged
Conversation
juliusknorr
approved these changes
Oct 15, 2026
juliusknorr
left a comment
Member
There was a problem hiding this comment.
Thanks a lot for this, change makes sense 👍
Member
|
/backport to stable35 |
…e page A federated file is edited through /apps/richdocuments/remote on the instance that owns it, embedded in an iframe on the initiator instance. Since the origin hardening, document.js sends every message for the parent window to its own origin. In this case the parent is the initiator, so the browser drops them all, including UI_Close: the viewer on the initiator stays open over an empty page. Pass the origin of the initiator to the page. The remote endpoint only renders after the initiator passed the trusted server check and its token was confirmed, so the value is verified. Messages from that origin are accepted as well, so the initiator can still talk to the editor. Fixes nextcloud#6094 Signed-off-by: Rikdekker <Rikdekker@users.noreply.github.com> Assisted-by: ClaudeCode:claude-opus-5-5
ArtificialOwl
force-pushed
the
fix/federated-parent-origin
branch
from
October 20, 2026 11:53
01a6228 to
d22fa75
Compare
Member
|
rebase since #6209 should have fixed the faulty test |
Member
|
/backport to stable34 |
Member
|
/backport to stable33 |
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A federated file is edited through
/apps/richdocuments/remoteon the instance that owns it, embedded in an iframe on the instance the user is on (the initiator). Since #5874,document.jssends every message for the parent window towindow.location.origin. On the remote page that is the owner's origin, not the parent's, so the browser drops all of them:Closing the document never reaches the initiator. The owner hides its editor, the viewer on the initiator stays open over the empty owner page, and the URL keeps
openfile=true&editing=false. Escape or a reload gets out of it.This passes the initiator's origin to the page as
parentOrigin, anddocument.jsuses it as the target origin forparentand accepts messages from it. The value comes from the server, not the query string:remote()only renders aftergetRemoteFileDetails()has checked thatremoteServeris a trusted server and confirmed the token with it. Pages that are not opened throughremote()get noparentOriginand keep using their own origin.The fix proposed in #6094 reads
remoteServerfrom the query string withgetSearchParam(). That helper decodes withdecodeURI(), which leaves%3Aand%2Fencoded.new URL()then throws, and the code falls back to the page's own origin, so the bug stays.The second commit drops
_.bind()from the remote page. Server 36 no longer provides the underscore global, so onmainthe remote page threw_ is not definedbefore the editor loaded. Without the binding the handler is the same, sinceonCloseonly refers todocumentsMain. Server 33 still has the global, so on stable33 this commit changes nothing.How I tested
One dev container (
npm run dev:server) acting as two instances through two origins: the owner onhttp://127.0.0.1:8081, the recipient onhttp://localhost:8081, with a federated share between them and both origins as trusted servers. Collabora needs--o:net.frame_ancestors=127.0.0.1:*for this. A Playwright script opens the shared document as the recipient, clicks Collabora's close button and checks the viewer.…?dir=/&editing=false&openfile=true…?dir=/postMessageorigin errors in the consoleDone on stable33 (server 33.0.10 RC1, 10.3.2 without and with the first commit) and on
main(server master, both commits). On both, a local, non-federated document still opens and closes.DocumentControllerTestpasses on both, and the new test fails without the change to the controller.The Cypress test for federated documents (
share-federated.spec.js) is skipped, and it runs on a single origin, so it could not have caught this.Checklist
/backport to stable35 please
/backport to stable34 please
/backport to stable33 please
/backport to stable32 please
/backport to stable31 please
/backport to stable30 please
/backport to stable29 please
🤖 Generated with Claude Code