Skip to content

fix(env): strip surrounding quotes from .env values#95

Open
webframp wants to merge 1 commit intocalesthio:masterfrom
webframp:fix/env-quoted-values
Open

fix(env): strip surrounding quotes from .env values#95
webframp wants to merge 1 commit intocalesthio:masterfrom
webframp:fix/env-quoted-values

Conversation

@webframp
Copy link
Copy Markdown

Problem

The custom .env parser in apis/utils/env.mjs does not handle quoted values. Passwords and API keys containing special characters (|, ^, ", >, [, #, etc.) either parse incorrectly or include the quote characters as part of the value.

For example, an ACLED password like:

ACLED_PASSWORD='Fvb|=K^j6"}ceIOtv^45>w/[3'

would be parsed as 'Fvb|=K^j6"}ceIOtv^45>w/[3' (with the surrounding quotes included), causing authentication failures.

Fix

Strip matching surrounding quotes (single or double) from values after trimming, consistent with how dotenv and other standard .env parsers behave.

Changes

  • apis/utils/env.mjs: Added quote-stripping logic (4 lines)

Testing

Verified that:

  • Unquoted values continue to work as before
  • Single-quoted values with special characters parse correctly
  • Double-quoted values parse correctly
  • Values with mismatched or internal quotes are left untouched

The custom .env parser did not handle quoted values, causing passwords
and API keys containing special characters (|, ^, ", >, [, etc.) to
include the quote characters as part of the value or parse incorrectly.

This adds quote stripping for both single and double-quoted values,
matching the behavior of dotenv and other standard .env parsers.

Co-authored-by: Shelley <shelley@exe.dev>
@webframp webframp requested a review from calesthio as a code owner April 20, 2026 04:15
@webframp
Copy link
Copy Markdown
Author

Fine if you want to reject this or solve a different way and I'm not sure of repo policy on AI developed code. I hit this issue when using a complex password for the ACLED_PASSWORD value

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