Repository navigation
π‘οΈ Preserve and restore the previous PDF handler - #67
Merged
Merged
Conversation
Record the original PDF handler exactly once into a private no-follow file and provide an explicit restore action that refuses to override a user-changed default or a missing application. Co-authored-by: ChatGPT # 6 <noreply@openai.com>
Test once-only private backup, no overwrite on reinstall, symlink and malformed-state rejection, and exact application verification before restoration. Co-authored-by: ChatGPT # 6 <noreply@openai.com>
Deploy the native history helper and capture the existing PDF association once before the installer switches to PDF Magic Opener; fail closed on unsafe state. Co-authored-by: ChatGPT # 6 <noreply@openai.com>
Compile the Swift helper and run isolated backup, symlink, validation, and restore regression tests. Co-authored-by: ChatGPT # 6 <noreply@openai.com>
Explain secure history storage, explicit restoration, refusal to overwrite newer user defaults, and the security impact of bypassing the opener after restoration. Co-authored-by: ChatGPT # 6 <noreply@openai.com>
Evaluate the throwing file read outside Swift's nonthrowing precondition autoclosure without altering production behavior. Co-authored-by: ChatGPT # 6 <noreply@openai.com>
Preserve existing PDF default verification and user-action utilities while keeping backup capture immediately before the installer changes the default association. Co-authored-by: ChatGPT # 6 <noreply@openai.com>
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
Implement opener-0116, checklist Β§2.4 β record the previous PDF handler during installation and offer an explicit way to restore it.
pdf-handler-history.swiftwith arecordcommand that queries the actual macOS Launch Services PDF association and writes its original bundle ID toprevious-pdf-handler.txtonly on the first installation. The backup is private (0600), created exclusively and without following symlinks, and is never replaced on reinstallation.recordimmediately before the installer changes the PDF default. If the handler is unknown or saved state is unsafe, fail closed rather than silently losing the user's original default. Do not invent a prior default if the opener was already registered.restorecommand that validates the saved identifier, ensures PDF Magic Opener still owns the PDF association, resolves the installed previous application by bundle ID, verifies its executable and identity, and changes the default only on an explicit restore request. Verify the resulting Launch Services association.Tests
test-pdf-handler-history.swiftexercises once-only backup, private permissions, protection against symlinks and malformed state, unknown or self-referential original handlers, and fail-closed restoration of missing, altered, or user-replaced PDF handlers. The existing macOS job compiles and runs the new fixtures; the full scanner suite remains unchanged.Coordination
The existing PDF default read-only lookup (#59) is preserved. Open PR #62 separately verifies the default-setting utility and open PRs #65/#66 cover detecting/optionally restoring PDF Magic Opener itself; this task concerns recording and restoring the previous application and does not replace or duplicate those changes. If the installer opt-in workflow from #66 merges, the record step must remain directly before any opted-in association change rather than recording a declined selection.
Safety
No secret-bearing files are read. The backup includes only a validated bundle identifier, never PDF contents or source paths. All changes are confined to
PDF-magic/opener. Do not squash merge unless bothscanner-testsandmacos-buildpass on the integrated head.