Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dotenv): handle single-quotes in values in stringify() #5846

Merged
merged 5 commits into from
Aug 29, 2024

Conversation

emersonlaurentino
Copy link
Contributor

Currently, stringify has a bug to parse JSON string.

Here is an example:

input { FOO: "{'key': 'value'}" }
input_stringify FOO='{\'key\': \'value\'}'
parsed_input { FOO: "{\\" }

After fix

input { FOO: "{'key': 'value'}" }
input_stringify FOO="{'key': 'value'}"
parsed_input { FOO: "{'key': 'value'}" }

Codebase to test

const input = { FOO: "{'key': 'value'}" };
const input_stringify = dotenv.stringify(input);
const parsed_input = dotenv.parse(input_stringify);

console.log("input", input);
console.log("input_stringify", input_stringify);
console.log("parsed_input", parsed_input);

@CLAassistant
Copy link

CLAassistant commented Aug 27, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

codecov bot commented Aug 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.26%. Comparing base (baa5086) to head (2d2e09b).
Report is 14 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5846   +/-   ##
=======================================
  Coverage   96.26%   96.26%           
=======================================
  Files         479      479           
  Lines       38763    38712   -51     
  Branches     5623     5619    -4     
=======================================
- Hits        37314    37268   -46     
+ Misses       1406     1401    -5     
  Partials       43       43           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@iuioiua iuioiua changed the title fix: Improve handling of special characters in dotenv stringify fix(dotenv): handle single-quotes in stringify() Aug 29, 2024
@iuioiua iuioiua changed the title fix(dotenv): handle single-quotes in stringify() fix(dotenv): handle single-quotes in values in stringify() Aug 29, 2024
Copy link
Contributor

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

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

Nice. Thank you for your contribution!

@iuioiua iuioiua merged commit 8b9a139 into denoland:main Aug 29, 2024
18 checks passed
@emersonlaurentino emersonlaurentino deleted the stringify-bug branch August 30, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants