fix: #5757 restore pasted URL page titles through host transport by Jocs · Pull Request #5756 · marktext/marktext · GitHub
Skip to content

fix: #5757 restore pasted URL page titles through host transport - #5756

Merged
Jocs merged 2 commits into
developfrom
fix/paste-url-page-title
Oct 15, 2026
Merged

Jocs merged 2 commits into
developfrom
fix/paste-url-page-title

Conversation

@Jocs

@Jocs Jocs commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Closes #5757

Relates to #1344 and #2525.

Summary

Restore page-title labels when pasting bare HTTP(S) URLs. The renderer's default-src 'self' CSP blocks its existing cross-origin fetch, and relaxing CSP alone would still leave target-site CORS restrictions.

Muya now accepts an optional fetchLinkHtml transport hook, while title parsing, entity decoding, the 1.5-second deadline, URL fallback, and paste behavior remain in the standalone package. Without a hook, Muya keeps its browser-fetch fallback. MarkText supplies the hook through typed preload/IPC to an Electron main-process request; the renderer CSP remains unchanged.

Also recognize URLs without a path, avoid HTML interpolation when promoting a plain URL, and skip title lookups for plain-text paste. The desktop transport accepts only HTTP(S), sends no session credentials, aborts after 1.5 seconds, and caps HTML at 1 MiB.

Type of change

  • Bug fix (non-breaking, fixes an issue)

Test plan

  • 189 Muya clipboard/title tests pass, including host transport, browser fallback, entities, timeouts, host-only URLs, and skipping plain-text lookups.
  • 10 desktop transport/IPC tests pass, covering response handling, protocol validation, credential omission, response size limits, network errors, and aborts.
  • 3 Electron E2E tests pass: a local server without CORS headers remains blocked from direct renderer fetch but supplies a title through paste; plain-text paste sends no request; failures preserve the URL.
  • Root lint, desktop typecheck, Muya lint/typecheck, and circular dependency checks pass (existing lint warnings remain).
  • Production build (pnpm run build:unpack) passes.
  • Tested on macOS.

Notes for reviewers

Independent of #5755, which handles preserving selected text when pasting a URL. This PR does not include that selection behavior.

Muya's timeout stops waiting for an injected hook; each host owns cancellation and size limits for its transport. The new option is documented in the Muya README and TypeScript interface.


By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@Jocs
Jocs force-pushed the fix/paste-url-page-title branch from 66bb074 to 660c567 Compare October 15, 2026 12:32
@Jocs Jocs changed the title fix: restore pasted URL page titles through host transport fix: #5757 restore pasted URL page titles through host transport Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

@Jocs
Jocs force-pushed the fix/paste-url-page-title branch from 69bb959 to 9fc07e8 Compare October 15, 2026 13:19
@Jocs
Jocs merged commit d4aa7f1 into develop Oct 15, 2026
18 checks passed
@Jocs
Jocs deleted the fix/paste-url-page-title branch October 15, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Pasted URL page titles are blocked by renderer CSP

1 participant