Skip to content

[Fix] Site .env: stop escaping double quotes in values that never needed quoting - #1228

Merged
RichardAnderson merged 2 commits into
vitodeploy:4.xfrom
RichardAnderson:fix/1227
Aug 8, 2026
Merged

[Fix] Site .env: stop escaping double quotes in values that never needed quoting#1228
RichardAnderson merged 2 commits into
vitodeploy:4.xfrom
RichardAnderson:fix/1227

Conversation

@RichardAnderson

@RichardAnderson RichardAnderson commented Aug 7, 2026

Copy link
Copy Markdown
Member

EnvParser::stringify() treated any " or ' in a value as requiring double-quote wrapping plus backslash escaping, which rewrote valid JSON like ["ideal","paybybank"] as "["ideal","paybybank"]" and broke Vite and other consumers that don't unescape quotes - it now emits the minimal dotenv form (bare when safe, single-quoted when that avoids escaping, double-quoted-and-escaped otherwise), which also heals already-corrupted files on the next save.

Closes #1227

Summary by CodeRabbit

Bug Fixes

  • Improved handling of environment values containing spaces, hash symbols, quotes, tabs, and carriage returns.
  • Environment values are now quoted and escaped correctly while preserving unchanged values where possible.
  • Improved serialisation and round-tripping of JSON array values in environment configuration.

Tests

  • Added coverage for quote selection, escaping, special characters, JSON formats, and payment-method configuration updates.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c38c1928-8c4c-4cba-b0f2-9caa66b766d3

📥 Commits

Reviewing files that changed from the base of the PR and between d75b745 and 45d6515.

📒 Files selected for processing (2)
  • app/Helpers/EnvParser.php
  • tests/Unit/EnvParserTest.php

📝 Walkthrough

Walkthrough

The PR updates environment-value parsing and stringification. It adds quote selection, escaping for special characters, carriage-return parsing, and coverage for JSON values and uploaded .env content.

Changes

Environment serialisation

Layer / File(s) Summary
Conditional value quoting
app/Helpers/EnvParser.php, tests/Unit/EnvParserTest.php
stringify keeps simple values unquoted, selects single quotes where possible, and uses escaped double quotes for complex values. Tests cover JSON arrays, quote styles, hash-prefixed values, tabs, carriage returns, and round-tripping.
Uploaded environment validation
tests/Feature/ApplicationTest.php
The test captures the SSH fake and verifies that VITE_PAYMENT_METHODS_MOLLIE is uploaded as a serialised .env assignment.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: saeedvaziry

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: preventing unnecessary escaping of double quotes in .env values.
Linked Issues check ✅ Passed The implementation and tests address issue #1227 by preserving valid JSON values during .env save operations.
Out of Scope Changes check ✅ Passed All code and test changes support the linked issue and the stated .env serialisation objectives.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/Helpers/EnvParser.php`:
- Around line 194-195: Update EnvParser::stringify() to escape carriage returns
as the literal \r sequence alongside backslashes, newlines, and quotes; update
the double-quoted parsing logic to decode that escape back to an actual carriage
return. Adjust the carriage-return round-trip test to assert the escaped on-disk
representation while preserving the original value after reload.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8080d6eb-6060-4ab8-86be-a423afb04e8c

📥 Commits

Reviewing files that changed from the base of the PR and between dc75758 and d75b745.

📒 Files selected for processing (3)
  • app/Helpers/EnvParser.php
  • tests/Feature/ApplicationTest.php
  • tests/Unit/EnvParserTest.php

Comment thread app/Helpers/EnvParser.php Outdated
@RichardAnderson
RichardAnderson merged commit 30f5074 into vitodeploy:4.x Aug 8, 2026
6 checks passed
@RichardAnderson
RichardAnderson deleted the fix/1227 branch August 8, 2026 11: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

2 participants