Skip to content

fix: serialize launchd plist safely - #64

Merged
Jeomon merged 1 commit into
CursorTouch:mainfrom
git-ksk:fix/launchd-plist-serialization
Aug 26, 2026
Merged

fix: serialize launchd plist safely#64
Jeomon merged 1 commit into
CursorTouch:mainfrom
git-ksk:fix/launchd-plist-serialization

Conversation

@git-ksk

@git-ksk git-ksk commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace manual XML string interpolation in _build_plist() with plistlib.
  • Preserve the existing launchd keys and values.
  • Safely encode special characters in executable paths, arguments, and log paths.

Reproduction

With the current implementation, a ProgramArgument such as /tmp/tool&name or a config/log path containing &, <, or > is inserted into XML unescaped. Parsing the generated plist then fails with ExpatError: not well-formed.

Root cause

_build_plist() manually interpolates arbitrary strings into XML <string> elements instead of using a plist serializer.

Validation

  • focused special-character round-trip test: 1 passed
  • full suite: 320 passed
  • generated plist passes macOS plutil -lint
  • special characters round-trip through the generated plist unchanged
  • git diff --check: clean
  • no added line exceeds the repository's 100-character limit
  • ruff check .: 462 findings, identical to upstream/main's pre-existing baseline
  • ruff format --check .: same 26 pre-existing unformatted files as upstream/main; the new test file is formatted

Compatibility

The generated plist keeps the same launchd semantics:

  • Label
  • ProgramArguments
  • RunAtLoad
  • KeepAlive
  • StandardOutPath
  • StandardErrorPath

Only serialization/escaping is changed; textual XML formatting is intentionally not treated as an API.

Non-changes

@Jeomon
Jeomon merged commit e79e096 into CursorTouch:main Aug 26, 2026
@git-ksk
git-ksk deleted the fix/launchd-plist-serialization branch August 27, 2026 06:17
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.

2 participants