nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] Daemon install writes the LaunchAgent plist without XML escaping and leaves spaces and % in the systemd unit unquoted

Open addyCooks opened this issue 2 weeks ago • 2 comments

Description

buildLaunchAgentPlist writes the project path straight into XML, so & or < in the path makes the plist invalid. buildSystemdUnit writes the path unquoted in Environment= (a space splits it into two assignments) and leaves a single %, which systemd treats as a specifier. I checked the generated text only. I did not load either file with launchd or systemd.

Environment

  • OS: Windows 11 Home 10.0.26300
  • Node version: v22.22.3
  • Nanocoder version: 1.32.0 (built from main at 5df35b3a)
  • Provider: Not provider-specific
  • Model: Not model-specific

Steps to Reproduce

  1. Call buildLaunchAgentPlist('/Users/me/R&D <x>', 'abc', 'nanocoder').
  2. Call buildSystemdUnit('/home/me/my proj/100%', 'abc', 'nanocoder').

Expected Behavior

  • The plist contains R&amp;D &lt;x&gt;.
  • The unit writes % as %% and quotes the value: Environment="NANOCODER_PROJECT_ROOT=/home/me/my proj/100%%".

Actual Behavior

<string>/Users/me/R&D <x></string>
Description=nanocoder daemon for /home/me/my proj/100%
WorkingDirectory=/home/me/my proj/100%
Environment=NANOCODER_PROJECT_ROOT=/home/me/my proj/100%

Additional Context

  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] I can reproduce this issue consistently
  • [x] This issue occurs with the latest version of nanocoder (main)

Suggested fix:

  • source/daemon/install.ts:131, :136 and :140: wrap the values in the existing xmlEscape (defined at line 177 for the Task Scheduler manifest).
  • source/daemon/install.ts:157-163: replace % with %% in all values and put the Environment= assignment in double quotes.
  • Add tests with &, <, a space and % in the path.

addyCooks avatar Nov 16 '26 09:11 addyCooks

I'd like to work on this. On main at 5df35b3a I ran the two calls from the issue: the plist has <string>/Users/me/R&D <x></string>, and macOS plutil -lint rejects it (Encountered unknown ampersand-escape sequence at line 14); the unit has Environment=NANOCODER_PROJECT_ROOT=/home/me/my proj/100%, as the issue shows. I'll try the suggested change with tests for &, <, a space and %, and post the result or a blocker here within two days.

hskl18 avatar Nov 16 '26 18:11 hskl18

Sure @hskl18, go ahead

akramcodez avatar Nov 19 '26 09:11 akramcodez