Skip to content

fix: run ffmpeg and ffprobe without a shell - #351

Merged
kikootwo merged 4 commits into
mainfrom
fix/run-media-tools-without-shell
Oct 19, 2026
Merged

kikootwo merged 4 commits into
mainfrom
fix/run-media-tools-without-shell

Conversation

@kikootwo

Copy link
Copy Markdown
Owner

What changed

  • ffprobe and ffmpeg (chapter merging, bulk-import scanning, the encoder check) now start directly with an argument list instead of through a shell command line, so file and folder names reach them exactly as they are on disk.
  • Metadata values are passed as is. That also fixes merged books whose title contains " getting a stray leading quote or backslashes.
  • The free-disk-space check uses fs.statfs instead of a df | tail | awk pipeline.
  • Chapter merging reads its file list through ffmpeg's file protocol only. A book whose file names contain a line break (which the list format can't hold) is organized as individual files instead of merged.

Why

Building shell command strings out of file names is fragile. Quotes and special characters in a book's folder name could break probing and merging, and paths don't need to go through a shell at all.

Evidence

  • Unit tests cover the arguments each tool receives, the merge list contents, and a real ffmpeg/ffprobe round trip on file names with quotes and special characters.
  • End-to-end on a disposable Docker stack: smoke passes, and a download whose folder name contains quotes and special characters is probed and organized from its literal path.

Full logs: https://gist.github.com/kikootwo/73320e52e0cafe0af9b0e0d5514cc32d

Checks

  • Image build (dockerfile.unified): PASS, ffmpeg 9.0.2 in the image
  • Unit suite (Node 20, 2646 tests): PASS
  • E2E (smoke, special-character folder names): PASS

Risk and rollback

This changes every ffmpeg and ffprobe call site (probe, merge, tagging, the encoder check). The unit and end-to-end runs above cover them. Reverting this PR restores the previous invocation.

🤖 Generated with Claude Code

kikootwo and others added 4 commits October 19, 2026 12:46
- chapter-merger, bulk-import-scanner: ffprobe, ffmpeg decode checks and
  `ffmpeg -encoders` use execFile with argv arrays; the merge builds its
  argv directly for spawn instead of tokenizing a command string
- metadata values are passed verbatim, which also fixes titles containing
  `"` gaining a stray leading quote or backslashes
- disk space check uses fs.statfs instead of a df|tail|awk pipeline
- concat merge: limit inputs with -protocol_whitelist file,pipe and refuse
  file names containing control characters (the list format is line-based);
  such books fall back to organizing files individually
- tests: real ffmpeg/ffprobe round-trip with metacharacter file names
  (skips when the binaries are absent) plus argv-level unit tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- concat inputs may only use the file protocol (drop pipe)
- refuse only paths containing a line break or NUL (the characters that end
  a concat list line); report the full path
- strip CR and NUL as well as LF from chapter titles in the ffmetadata file
- move argv/list-file safety tests to chapter-merger-argv.test.ts and assert
  the concat list content directly
- correct the statfs disk-space comment

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kikootwo
kikootwo merged commit 77cdb73 into main Oct 19, 2026
2 checks passed
@kikootwo
kikootwo deleted the fix/run-media-tools-without-shell branch October 19, 2026 18:45
kikootwo added a commit that referenced this pull request Oct 19, 2026
.dockerignore: keep main's redis + .claude entries and the e2e/ line.
documentation/testing.md: list all three workflows plus the e2e harness.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kikootwo added a commit that referenced this pull request Oct 19, 2026
- port the media-tools-without-a-shell acceptance spec into
  e2e/specs/regressions/sec-shell-exec.spec.ts (bridge exec + new
  read-only logs op, control token); skipped on tainted runs
- exec bridge: read-only logs operation; host tests for request
  validation, tainted refusal and token checks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kikootwo added a commit that referenced this pull request Oct 19, 2026
Adds the e2e/ harness: disposable Docker stacks with fake Prowlarr, qBittorrent, SABnzbd and Plex and a real Audiobookshelf, specs in a pinned Playwright container (smoke on both backends, upgrade from 1.2.3, regression specs for #242, #275 and #351), containerized offline unit runs, and an explicit trusted/tainted declaration with tainted mode switched off until build-time isolation lands. e2e/ is excluded from the app image and build. Harness self-tests, unit suite and stack runs passed; PR Tests passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant