Support Mermaid without Prism and safe local wiki links#520
Draft
leevi2010-cursor wants to merge 1 commit into
Draft
Support Mermaid without Prism and safe local wiki links#520leevi2010-cursor wants to merge 1 commit into
leevi2010-cursor wants to merge 1 commit into
Conversation
schuyler
requested changes
Jul 11, 2026
Owner
There was a problem hiding this comment.
Thanks for the PR, @leevi2010-cursor!
Issues
- Reinvents path-safety instead of reusing MPURLSecurityPolicy: the wiki-link resolver uses an inline character blacklist that doesn't resolve symlinks, rather than the existing CVE-motivated
MPURLSecurityPolicycontainment check, so the two "safe local file" definitions can drift and a symlinked.mdtarget isn't caught. - XSS-escaping of link labels is unverified: labels are escaped only for Markdown metacharacters, not HTML, and a payload like
[[note|<script>…]]re-enters Hoedown, so a test confirming the output is entity-escaped would close this (and reveal a real issue if the assumption is wrong). - Fragile dependency on preview base-URL internals: wiki-link resolution recovers the document directory from
previewSafeBaseURL:'s WebKit sentinel path, an accidental coupling that isn't tested against the real document delegate and would break silently if that scheme changes. - Export path untested: the Mermaid-without-Prism change was applied identically to the HTML export path but only the preview path is tested, leaving the duplicated branch open to silent drift.
- Fence detection can misparse: matching fences by
hasPrefix:against a fixed three-backtick marker collapses different backtick counts, so a 4-backtick block can be closed by a 3-backtick line, differing from how Hoedown parses and risking linkification inside code blocks. - Inline code spans aren't preserved: wiki syntax inside single-backtick spans such as
`[[note]]`still gets linkified, contradicting the "code preserves literal syntax" intent that fenced blocks honor.
Suggestions
- Empty or whitespace-only targets (
[[]],[[ |x]]) currently vanish from the output instead of staying as plain text. - Coverage is missing for several defensible-but-unverified cases: absolute-path targets, a nil base URL (unsaved document),
~/percent-encoded traversal, and the "neither Mermaid nor Prism" combination. - The
rendererBaseURL:doc comment and the Quick Look "Excluded features" comment are now out of date given wiki links, and the[[note]]syntax has no user-facing documentation. - A resolved link's label gets a second Markdown pass (so
[[note|a*b*]]italicizes), and documenting that as intended would settle it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two main-preview compatibility gaps for Markdown knowledge-base documents:
[[note]]and[[note|label]]wiki links render in prose and tables.mdfiles in the current document directoryQuick Look intentionally remains unchanged: it disables JavaScript and explicitly excludes Mermaid for sandbox, startup-cost, and security reasons. This PR fixes the main document preview without conflating that separate product boundary.
Testing
MPMermaidRenderingTests: 17 passedMPMarkdownRenderingTests: 71 passedMPHtmlPreferencesViewController.xibThe wiki-link implementation is intentionally narrow. It does not add vault indexing, title lookup, backlinks, embeds, headings, or graph behavior.