Closed Martinsos closed 3 months ago
Hi @Martinsos Thanks for reporting that. I think what you mention makes sense but I need to take a look at the parser to clarify if this is expected and what would be the correct way to handle breaking lines.
Thanks @CristhianMotoche !
I don't care much about the "\n" case, but "\n" being parsed as "n" is quite tricky, it makes it impossible to enter a string with a newline inside the env (and for example, Google gives you PEM key as a secret and it has newlines!). The only solution we found so far was to encode it with base64, putting it in .env like that, and then decoding it after being red for dotenv.
Let me know if I can help in some way!
Hey @Martinsos I was able to reproduce the issue. Indeed, it seems something wrong in the parser. FWIW, I think you can add new lines instead of the \n
character to represent new lines. For example:
Given this .env
:
BAR="a
b"
parseFile
will return:
ghci> parseFile ".env"
[("BAR","a\nb")]
I hope that works as a workaround until we find a solution for this issue.
Here is an .env file I used to illustrate the potential issue:
Now, when I run
parseFile "testenv"
inghci
, I get the following output:Formatted:
This is not the output I would expect though.
Output I would expect is the following:
Is my expectation wrong here, or is this potentially a bug in the Dotenv?
I am using
dotenv ^>= 0.10.0
.Thanks!