Skip to content

fix: Dockerfile.browser build + env-file quoting regression#356

Merged
bicced merged 1 commit intomainfrom
fix/review-followup-fixes
Mar 6, 2026
Merged

fix: Dockerfile.browser build + env-file quoting regression#356
bicced merged 1 commit intomainfrom
fix/review-followup-fixes

Conversation

@bicced
Copy link
Contributor

@bicced bicced commented Mar 6, 2026

Summary

Fixes two bugs found during principal engineer review of the production readiness changes:

  1. Dockerfile.browser build failure — Docker's parser strips continuation lines starting with # as Dockerfile comments, even inside shell strings. The CSS selector lines (#noVNC_logo, etc.) were being stripped, destroying the printf string and its closing quote. Fixed by putting the entire printf body on a single line.

  2. CRITICAL: _quote_env_value broke Docker --env-file parsing — Docker's --env-file reads values literally after = with no quote stripping or shell expansion. The previous implementation wrapped values in "..." and added shell escapes (\$, \`), which would pass literal quote characters to agent containers. This would crash agents on int(AGENT_PORT) (gets "8400" instead of 8400) and json.loads(MCP_SERVERS).

    Replaced with _sanitize_env_value that only escapes newlines (the one format-breaking character for line-based env files).

  3. Added test for newline sanitization in env values.

Test plan

  • docker build -t openlegion-browser:latest -f Dockerfile.browser . — builds successfully
  • pytest tests/test_runtime.py — 54 passed
  • pytest tests/ --ignore=tests/test_dashboard.py — 1595 passed, 45 skipped
  • Verified Docker --env-file treats quotes as literal: echo 'VAR="val"' → container gets "val" with quotes

1. Dockerfile.browser: Put CSS printf body on single line. Docker's
   parser strips continuation lines starting with '#' as comments,
   which destroyed the CSS selector content and broke the build.

2. runtime.py: Replace _quote_env_value with _sanitize_env_value.
   Docker --env-file reads values literally — no quote stripping or
   shell expansion. The previous implementation wrapped values in
   double quotes and added shell escapes, which would have passed
   literal quote characters to agent containers, crashing them on
   int(AGENT_PORT) and json.loads(MCP_SERVERS).

   The only escaping needed is newline → \n (two chars) to prevent
   env-file injection via multi-line values.

3. Added test for newline sanitization in env values.
@bicced bicced merged commit 6b4aced into main Mar 6, 2026
3 checks passed
@bicced bicced deleted the fix/review-followup-fixes branch March 6, 2026 14:09
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