Skip to content

Strip CRLF line endings from env_file values - #30

Open
ericof wants to merge 1 commit into
mainfrom
issue-28
Open

ericof wants to merge 1 commit into
mainfrom
issue-28

Conversation

@ericof

@ericof ericof commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Fix: Strip CRLF line endings from environment variables

Problem

When users edit multi-line GitHub secrets or environment variables via the repository settings web form, GitHub stores them with CRLF (carriage return + line feed) line endings. The env_file and env_file_path inputs were not stripping the trailing \r characters, so:

  • strconv.Atoi: parsing "2\r" errors for numeric values
  • Database credentials with \r at the end are rejected as invalid
  • Values appear correct visually but fail at runtime

Solution

Modified load_env_file() in scripts/docker-entrypoint.sh to:

  1. Detect and strip trailing \r from each line before validation and export
  2. Count and report stripped lines to alert users of the CRLF issue
  3. Match existing behavior of trim_inputs() for whitespace problems

The fix applies to both env_file (inline secrets) and env_file_path (file-based variables).

Testing

Added 10 new tests covering:

  • CRLF values are exported correctly without the trailing \r
  • Multiple CRLF lines are counted in the report
  • LF-only input is not falsely reported as having CRLF
  • CRLF comment lines are still skipped
  • Both env_file and env_file_path handle CRLF correctly

Verification: All 8 CRLF-related tests fail without the fix and pass with it.

Total tests: 67 → 77 (10 new tests added)
Lint: Passes


Closes #28

Fixes issue #28: env_file and env_file_path now strip trailing carriage returns
from each line, which GitHub's web form stores when editing multi-line secrets.
Every affected line is reported, matching the behavior of trim_inputs for
whitespace issues.

The fix:
- Detects trailing \r on each line in load_env_file
- Strips it before blank/comment/format checks
- Counts and reports stripped lines to alert users of the issue
- Works for both env_file and env_file_path inputs
- Does not affect LF-only input (no report issued)

Tests added:
- CRLF values are exported without the \r
- Multiple CRLF lines are counted and reported correctly
- LF-only input does not trigger a report
- CRLF comment lines are still skipped
- Both env_file and env_file_path handle CRLF correctly

Closes #28
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.

env_file keeps the \r of CRLF line endings in every value

1 participant