You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
block automatic creation of missing file-link targets that resolve outside the current document scope
stop the auto-create path immediately for unsaved documents instead of falling through after the alert
add document-level regression tests covering saved, unsaved, in-scope, out-of-scope, and symlink-escape link targets
Why
When createFileForLinkTarget was enabled, clicking a missing Markdown file link could create an empty file anywhere the user could write, not just beside the current document. A crafted link could therefore create arbitrary files outside the document tree.
Root cause
The preview link handler validated executable targets when opening existing files, but the auto-create branch passed unresolved file URLs straight to createNewEmptyDocumentForURL: without checking whether the target stayed within the current document scope.
Validation
xcodebuild test -workspace "MacDown 3000.xcworkspace" -scheme MacDown -destination "platform=macOS"
Missing return after the unsaved-document alert — openOrCreateFileForUrl: falls through into the new scope check, so unsaved documents trigger two alerts in sequence for a single click.
Three small suggestions: a ### Security entry in CHANGELOG.md [Unreleased]; alertStyle = NSAlertStyleWarning on the new alert to match the adjacent code; a one-line comment on canAutomaticallyCreateLinkedFileAtURL: explaining the currentBaseUrl ?: fileURL fallback.
All requested review feedback changes have been addressed. The missing return statement was verified to be present, and the CHANGELOG.md entry, the NSAlertStyleWarning, and the fallback code comments have been successfully added.
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
rc-pendingIncluded in a release candidate awaiting validation
2 participants
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
Why
When
createFileForLinkTargetwas enabled, clicking a missing Markdown file link could create an empty file anywhere the user could write, not just beside the current document. A crafted link could therefore create arbitrary files outside the document tree.Root cause
The preview link handler validated executable targets when opening existing files, but the auto-create branch passed unresolved file URLs straight to
createNewEmptyDocumentForURL:without checking whether the target stayed within the current document scope.Validation
xcodebuild test -workspace "MacDown 3000.xcworkspace" -scheme MacDown -destination "platform=macOS"