nextcloud / nextcloud/richdocuments

urlsrc is used verbatim from cached discovery, so the editor only works on one Nextcloud address

Open
#6,019 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
453
Forks
147
Avg merge
14h 54m
Merged PRs (30d)
83

Description

Summary

urlsrc is taken verbatim from Collabora's cached WOPI discovery document and used directly as the editor iframe's src. Because that value is an absolute URL, a Nextcloud instance reachable at more than one address can only ever open documents on one of them.

The chain
  1. Service/DiscoveryService::getDiscoveryEndpoint() fetches /hosting/discovery from the single configured wopi_url, and the response is cached (CachedRequestService).
  2. WOPI/Parser::getUrlSrcValue() returns the urlsrc attribute verbatim — the only transformation is str_replace('\.', '.', …).
  3. That value reaches the front end as Config.get('urlsrc'), and src/helpers/url.js::getWopiUrl() concatenates it with the query parameters to form the iframe URL.
  4. coolwsd emits an absolute URL in urlsrc, derived from the Host of the discovery request (or from server_name when set).

So the origin baked into step 4 is fixed for every user and every session, regardless of which address they actually reached Nextcloud on.

public_wopi_url does not help: Service/ConnectivityService::autoConfigurePublicUrl() derives it from urlsrc (domainOnly($determinedUrl)) to feed the CSP. It is an output of discovery, not an override of it.

Impact

Any deployment where Nextcloud is reachable at more than one origin — a LAN address and a public domain, a .onion, split-horizon DNS — gets a working editor on exactly one of them and a blank frame on the rest. Self-hosted setups hit this routinely.

Expected

A way to have the editor load same-origin, for deployments that reverse-proxy Collabora underneath the Nextcloud origin (/browser, /cool, /hosting). Either:

  • an option to strip the scheme+host from urlsrc, leaving a root-relative URL the browser resolves against the current origin; or
  • treat a configured public_wopi_url as an override applied to urlsrc, rather than a value derived from it.
Notes

A root-relative urlsrc appears to work with no other change: nothing in the path validates it as absolute, and AddContentSecurityPolicyListener already adds 'self' as a frame domain. domainOnly('/browser/…') returns '', which getDomainList()'s array_filter drops, so no stale CSP origin is added either.

I have this working by rewriting the discovery response in the reverse proxy (Apache mod_substitute, stripping the origin from urlsrc and favIconUrl) — documents open and edit correctly on every address simultaneously. That works, but it is a workaround for something that seems like it should be configurable.

Versions: richdocuments 11.1.0, Nextcloud 34.0.3, Collabora Online Development Edition 26.04.3.2.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Service/DiscoveryService::getDiscoveryEndpoint() through WOPI/Parser::getUrlSrcValue(), src/helpers/url.js::getWopiUrl(), and ConnectivityService::autoConfigurePublicUrl(). Compare the proposed same-origin and public_wopi_url approaches, then verify that documents open from multiple Nextcloud addresses while the existing CSP handling remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, php
Domain
backend, frontend, full-stack, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.