Markpad icon indicating copy to clipboard operation
Markpad copied to clipboard

openPath is rejected by the opener scope, so "open the exported file" never works

Open PathGao opened this issue 4 months ago • 1 comments

After exporting a PDF or HTML, the app offers to open the result. It never can — openPath is refused before it reaches the OS.

Why

capabilities/default.json lists opener:allow-open-path, which grants the command. But scope is evaluated separately:

  • allow-open-path → commands: ["open_path"], scope: null
  • allow-default-urls → no commands, scope [mailto:*, tel:*, http://*, https://*]

A permission with no commands lands in the plugin's global scope, which applies to every opener command including open_path. And in tauri-plugin-opener 2.5.3:

// scope.rs
fn matches_path_program(&self, a: Option<&str>) -> bool {
    match self {
        Self::Url { .. } => false,        // <- every entry we have is a Url
        Self::Path { app, .. } => app.matches(a),
    }
}

is_path_allowed = fs_scope.is_allowed(path) && allowed.any(matches_path_program). Every scope entry is a Url, so the second conjunct is always false; the fs allow-list is empty, so the first is too. open_path returns ForbiddenPath in every window on every platform.

Where it shows

  • openExportedFile.ts — the "open the exported file?" prompt after a PDF/HTML export. This is the user-visible one.
  • It also blocks the fix for opening a relative link to a local non-markdown file ([data](./data.csv)), which currently falls through to openUrl with a webview-relative URL.

Fix

One entry in capabilities/default.json:

{ "identifier": "opener:allow-open-path", "allow": [{ "path": "**" }] }

** is the widest form and matches the existing assetProtocol.scope. If you'd rather scope it — the export directory and the open document's tree would cover both call sites — say so and I'll write that instead; it needs runtime scope calls rather than a static list.

Happy to PR whichever you prefer.

PathGao avatar Aug 02 '26 22:08 PathGao

Correcting my own description above — I overstated the scope of the symptom.

It is HTML export only, and it is a prompt, not an auto-open. askToOpenExportedFile has exactly one call site (exportAsHtml); PDF export never offers it. What the user sees is a yes/no dialog, "Open exported HTML file now?", and choosing Yes always fails.

The failure is also not silent — the call site catches it and shows toast.openExportedFileFailed ("Could not open exported file"). So the button has been visibly broken rather than quietly doing nothing, which is probably why it reads as an ordinary failure rather than a missing capability.

The ACL analysis in the original post is unaffected; only the blast radius was smaller than I wrote. Opening a PR with the fix rather than leaving this as a question — the two options differ by one string, not by what gets built, so review is a better place for it than an issue.

PathGao avatar Aug 02 '26 22:08 PathGao