fix(env): strip surrounding quotes from .env values#95
Open
webframp wants to merge 1 commit intocalesthio:masterfrom
Open
fix(env): strip surrounding quotes from .env values#95webframp wants to merge 1 commit intocalesthio:masterfrom
webframp wants to merge 1 commit intocalesthio:masterfrom
Conversation
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>
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The custom
.envparser inapis/utils/env.mjsdoes 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:
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
dotenvand other standard.envparsers behave.Changes
apis/utils/env.mjs: Added quote-stripping logic (4 lines)Testing
Verified that: