Skip to content

fix: escape shown text, keep project files in their folders, and start Windows agent shims directly - #40

Merged
nodemode-ai merged 12 commits into
mainfrom
fix/review-2026-11-28
Nov 29, 2026
Merged

nodemode-ai merged 12 commits into
mainfrom
fix/review-2026-11-28

Conversation

@gbarnai

@gbarnai gbarnai commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Escape the recovered project title in the restore bar, and the session names, agents, methods and job kinds in Settings, Connections, before they go into markup.

  • Project ids are an allowlist of the ids formcut issues: letters, digits, - and _, up to 64 characters, with no Windows device names. The file joined from an id must also resolve inside its folder. This guards opening a .fmc file, the cover routes, drawing covers on the home screen, and writing and deleting project records. Recovery keys must match whole.

  • Collect Files makes its destination folder with a single mkdir that fails when anything already has the name. It then takes the next free '<title> N', so an earlier collection, a file or a link of that name is never written into.

  • On Windows, a .cmd agent shim from npm or pnpm now runs its target directly: the program, or node and its script. Only when a shim cannot be followed does it go through cmd.exe, and then it refuses arguments the interpreter would read as syntax. This is the shared finder agent_lookup 1.0.2, and its hash is recorded in setup/agents.py.

  • The request guard and the RPC socket count only localhost and loopback addresses as this computer. The test suite adds the test client's names in conftest.

  • Tests: tests/test_project_ids.py, tests/test_windows_start.py, tests/test_shown_text_escaped.py, and new cases in tests/test_project_files.py and tests/test_family_guard.py. Each new test fails on the code before its fix.

  • On Windows, a .cmd or .bat agent program that cannot be followed to the program it wraps now starts through the command interpreter only when no argument holds & | < > ^ ( ) ! % " or a control character. The program path is checked too, and words with spaces are not exempt. The error message points long text to standard input or a file.

  • A package manager's .cmd shim is still run directly as an argv list, so every character in its arguments is passed on unchanged.

  • Tests that run on any OS cover both the direct path and the checked interpreter path.

  • Tests, check scripts and the CI engine steps now run with a home folder of their own, so a local run never writes into the real app data folder.

Tests

  • Each fix has a test that fails on the previous code where practical.
  • The repo CI commands were run locally on macOS. Every failure seen locally also fails on main in the same environment (missing local tools or platform-specific tests); none is introduced here.
  • Please rely on this PR's CI run for Linux and Windows.

For the owner

  • A few related items need an owner decision; they are listed separately, not here.

How to ship

  • Independent of other repos; merge in any order. No version bump; release as usual.

The restore bar on the home screen and the Connections list in Settings built
their rows as markup from text that comes from a saved journal or another
program. Both now go through escapeHtml, as the home cards already did.
…ction

Collect Files reused <folder>/<title> when it was already there, so a second
project of the same title replaced the first collection's footage and .fmc.
A folder already present is now left alone and the collection goes to
<title> 2, <title> 3 and so on, as files of the same name already were.
A project id is joined into the record, cover and delete paths, and opening a
.fmc file took whatever id it held. One check, store.safe_id (no folder
separator, no leading dot), now guards opening a file, the cover routes, the
home screen's cover drawing and deleting a project's record, as it already
guarded writing the records.
…uard

The guard accepted the test client's host names, testserver and testclient,
as loopback in every build. The engine now knows only localhost and loopback
addresses; the test suite adds the test client's names in conftest.
The check runs the engine in a child process without the suite's conftest, so
the test client's own host names are no longer taken as this computer there.
It now addresses the engine as 127.0.0.1, as the desktop app does.
A project id is joined into the record, cover and delete paths. The check
refused separators and a leading dot, but still let through a Windows drive
prefix such as C:x, device names such as CON, and other characters formcut
never puts in an id. store.safe_id now accepts only the ids formcut issues
(letters, digits, - and _, up to 64), and store.id_path also confirms that
the joined file resolves inside its folder, so a link that leads out of the
folder is not followed. Recovery keys are matched whole, so a key with a
trailing newline is refused as well.
Collect Files checked whether <title> was there and then made its folders
with parents allowed, so a link standing under that name, or a folder made
in between, was still written into. The destination folder is now made
with a single mkdir that fails when anything has the name, and the next
free "<title> N" is taken instead.
An agent program installed by npm or pnpm is a .cmd shim, and it was run
through cmd.exe /c, which reads %, quotes and & | < > ^ in the arguments
(a first message for a Claude Code tab among them) as its own syntax. The
shared finder (agent_lookup 1.0.2) now reads the shim and runs what it
points at directly: the program, or node and its script. Only when the
shim cannot be followed does it use the interpreter, and then it refuses
any argument with a control character, %, ! or a quote, and & | < > ^ or
brackets in a word that is not quoted. A batch file name in any case or
with a trailing dot is treated the same way. The new version's hash is
recorded in setup/agents.py.
The socket compared its peer against a fixed list that also named the test
client. It now uses security.loopback, which the test suite extends in
conftest, and a socket without a known peer is closed.
…line

When a .cmd or .bat file cannot be followed to the program it wraps and
has to start through the command interpreter, any argument (the program
path included) holding & | < > ^ ( ) ! % a quote or a control character
is now refused, with or without spaces, since the interpreter and the
shim's %* act on them even inside quotes. The message points long text
to standard input or a file. A followed shim still gets every argument
unchanged as an argv list. The recorded hash for agent_lookup 1.0.2 in
setup/agents.py is updated to match.
tests/conftest.py points HOME, USERPROFILE, LOCALAPPDATA, APPDATA and the
XDG folders at a temporary folder before any engine module is imported,
and puts them back and removes it in pytest_unconfigure. The suite already
had its own FORMCUT_DATA_DIR, but the per-user ffmpeg folder and anything
else reached through the home folder were the person's own. The suite
drops PATH folders that hold an agent program, which can drop Homebrew's
bin and with it ffmpeg; the tests then found ffmpeg only because the
engine put the person's formcut/ffmpeg folder on PATH. ffmpeg and ffprobe
from a dropped folder are now linked beside the agent stand-ins.

setup/golden_frames.py and setup/output_checks.py ran the engine in
process with no data folder, so a run by hand wrote renders and jobs into
~/Library/Application Support/formcut. Both now call setup/scratch_home.py,
which points the home folders and FORMCUT_DATA_DIR inside one temporary
folder and removes it when the script ends. The window smoke engine also
gets the Windows and XDG folders inside its sandbox home, and the bench and
route steps in checks.yml get a data folder under the runner's temporary
folder.

tests/test_stand_in_home.py checks that the home folder, the per-user
ffmpeg folder and the default data folder resolve inside the stand-in, and
that the data folder read at import is the suite's own.
@gbarnai
gbarnai requested a review from nodemode-ai as a code owner November 29, 2026 19:12
…on Windows

On Windows the system temporary folder is inside the home, so the suite's
own data folder from tempfile.mkdtemp was always under the person's home
and the stand-in home test failed there. The whole-home check now runs
only where the temporary folder is outside the home, and every system
checks that the data folder is not the person's own formcut data folder,
worked out from the variables as they were before the stand-in home.

Checked: tests/test_stand_in_home.py passes on Linux and ruff is clean;
the Windows paths from the failed run were checked by hand. Not run on
Windows.
@nodemode-ai
nodemode-ai merged commit ba54cdb into main Nov 29, 2026
8 checks passed
@nodemode-ai
nodemode-ai deleted the fix/review-2026-11-28 branch November 29, 2026 19:46
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