Skip to content

fix(editor): accept http(s) addresses for linked images - #421

Merged
AndyScherzinger merged 1 commit into
mainfrom
fix/image-link-url
Oct 22, 2026
Merged

AndyScherzinger merged 1 commit into
mainfrom
fix/image-link-url

Conversation

@AndyScherzinger

@AndyScherzinger AndyScherzinger commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Fixes #178

The "Linked image" dialog never accepted an address: the field stayed red and OK did nothing. The vendored editor checks the address with /^(http|https|data)?\:\w+/, which needs a word character right after the colon, so every http:// and https:// address failed. It now accepts addresses that start with http://, https:// or data: (/^(https?:\/\/|data:)\S+/). The only change is that regex in vendor/kityminder-editor/kityminder.editor.min.js.

Images from other servers still won't display, because the editor's Content Security Policy only allows images from the Nextcloud server itself and from data: URLs. Allowing outside images is a privacy decision, so it is not part of this PR. This is wrong, see the correction. Image URLs on the same Nextcloud server and uploaded images (which are data: URLs) work.

Tested: checked the new regex against https://…, http://… and data:image/png;base64,… (accepted) and against ftp://…, javascript:…, https:// and an empty string (rejected). I have not yet tested the dialog in a running Nextcloud.

A backport to stable-0.1 follows.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI (N/A)

The image dialog only accepted an address when a word character followed
the scheme's colon, so every http:// and https:// address was marked
invalid and the dialog could not be confirmed. Accept addresses starting
with http://, https:// or data:.

Fixes #178

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@AndyScherzinger AndyScherzinger added bug Something isn't working AI assisted This PR contains AI-assisted commits labels Oct 21, 2026
@AndyScherzinger AndyScherzinger added this to the v0.2.0 milestone Oct 22, 2026
@AndyScherzinger
AndyScherzinger merged commit 3192bb0 into main Oct 22, 2026
8 checks passed
@AndyScherzinger
AndyScherzinger deleted the fix/image-link-url branch October 22, 2026 16:32
@AndyScherzinger

Copy link
Copy Markdown
Member Author

Correction to the description: images from other servers are not blocked. The editor iframe's Content Security Policy allows images from any origin (DisplayController::showMindmapViewer() calls addAllowedImageDomain('*')), so with this fix linked external images display as well, not only images from the Nextcloud server itself and data: URLs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI assisted This PR contains AI-assisted commits bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Insert image via 'Link to image' not working

1 participant