Markpad icon indicating copy to clipboard operation
Markpad copied to clipboard

Feature request: let users allow extra link schemes (claude://, obsidian://, vscode://, …)

Open MarekWo opened this issue 1 month ago • 1 comments

What happens

A link with an app-specific URI scheme does nothing when clicked in the preview, with no toast and no console error:

[open session](claude://claude.ai/epitaxy/local_269398c2-f021-4cfb-b9e8-aea3a1c9fdb2)
[open note](obsidian://open?vault=Work&file=Plan)
[open file](vscode://file/C:/src/app/main.ts:42)

Modifier keys (Ctrl/Shift/Alt + click) don't change anything. The OS handles these URIs fine (claude: is registered to the Claude desktop app here); Markpad never hands them over.

Tested on Markpad 2.9.1 (portable .exe), Windows 11. The code below is shared by every build, so the installed version behaves the same.

Why

There are two independent gates, and either one is enough to block the click:

  1. Sanitizer. ALLOWED_MARKDOWN_URI_REGEXP in src/lib/utils/sanitize.ts only accepts the DOMPurify default schemes plus asset:/tauri:. Anything else, claude: included, fails the regexp, so DOMPurify drops the href. followDocumentLink then sees no href and returns silently, which is why there's no "could not open" toast.
  2. Opener scope. src-tauri/capabilities/default.json grants opener:allow-open-url with the plugin's default URL scope (mailto:, tel:, http://*, https://*). Even with the href kept, openUrl('claude://…') would be rejected as a forbidden URL.

I understand both are deliberate, and I agree with the default. Some Windows protocol handlers have a history of abuse (ms-msdt:/Follina, search-ms:), so a .md file from the internet shouldn't be able to launch arbitrary handlers.

Use case

I keep generated Markdown dashboards with deep links into other local apps: a list of Claude Code desktop sessions (claude://…), notes in Obsidian (obsidian://…), files in VS Code (vscode://file/…). Markpad is an excellent reader for these (tabs and auto-reload are exactly what a live status file needs), but the links are the reason the file exists.

Proposal

An opt-in setting, "Additional link schemes", empty by default, so current behaviour and security are unchanged for everyone who doesn't touch it.

  • Each entry is a bare scheme name (claude, obsidian, vscode), validated against ^[a-z][a-z0-9+.\-]*$.
  • A built-in denylist that can't be overridden: javascript, vbscript, data, file, plus known-dangerous Windows handlers (ms-msdt, search-ms, search, ms-officecmd, …).
  • Sanitizer: build the URI regexp from the base list plus the user's schemes, for both the preview and the HTML export. The policy then stays in one place, as sanitize.ts intends.
  • Opening: capability scopes are static, so instead of widening opener:allow-open-url this could be a small Rust command (e.g. open_custom_scheme_url). It re-checks the scheme against the saved setting and the denylist, then calls the opener from Rust. The webview never gets a wider scope than it has today.
  • Optional: a one-time confirmation per scheme ("Open claude: links with the system handler?").

Workaround I'm using meanwhile

A local build of v2.9.1 with claude hardcoded in both places:

--- a/src/lib/utils/sanitize.ts
+++ b/src/lib/utils/sanitize.ts
-	`^(?:…|(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|asset|tauri):|…)`,
+	`^(?:…|(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|asset|tauri|claude):|…)`,
--- a/src-tauri/capabilities/default.json
+++ b/src-tauri/capabilities/default.json
-    "opener:allow-open-url",
+    {
+      "identifier": "opener:allow-open-url",
+      "allow": [{ "url": "claude://*" }]
+    },

It works, but I'd much rather run the official build. I'm happy to put together a PR for the settings-based version if the direction sounds right to you.

MarekWo avatar Nov 01 '26 09:11 MarekWo

Thanks for the detailed write-up. We're not going to take this on for now. VS Code's Markdown preview works the same way Markpad does today: links with schemes outside a short allowlist (http, https, mailto and its own vscode:) do nothing when clicked, with no prompt. We'd rather keep that default than add a setting that lets a downloaded file launch other apps. Your local build is the way to go in the meantime.

PathGao avatar Nov 27 '26 06:11 PathGao