★ wanayoo — archive 1999 https://github.com/theskumar/python-dotenv/issues/215Nouvelle recherche | Portail wanayoo
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

set_key doesn't escape values with quotes in them #215

Closed
soapergem opened this issue Dec 19, 2019 · 1 comment
Closed

set_key doesn't escape values with quotes in them #215

soapergem opened this issue Dec 19, 2019 · 1 comment

Comments

@soapergem
Copy link

@soapergem soapergem commented Dec 19, 2019

Suppose you have this code:

import dotenv
import json

key = "KEY_TO_SAVE"
value = json.dumps({"test": "me"})
dotenv.set_key(".env", key, value)

What I would expect to see is a .env file that looks like this:

KEY_TO_SAVE="{\"test\": \"me\"}"

However what I actually see is this:

KEY_TO_SAVE="{"test": "me"}"

Because of the lack of escaping quote character, dotenv has effectively changed the value I was trying to set. In this case, the value passed to dotenv is valid JSON, but the value dotenv saves to the file is not valid JSON.

@bbc2
Copy link
Collaborator

@bbc2 bbc2 commented Dec 19, 2019

Thank you for reporting this. I can confirm that it's an issue with Python-dotenv and your expectations are sensible. I'll work on a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.