-
Notifications
You must be signed in to change notification settings - Fork 14
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: Correctly parse newline and multiline strings in dotenv files #192
Conversation
where | ||
newlineChar = string "\\n" >> return '\n' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FranzGB I see normalChar
parses any char that doesn't need escape. Do you know why that doesn't include the \n
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Cris! Yes, basically this line escapedChar = (char '\\' *> anySingle) <?> "escaped character"
is eating all the \
not treating \n
as a single character and leaving just the n
as that is a candiate for normalChar
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do have another idea on how could we achieve this without adding a new function here (newlineChar <|> escapedChar <|> normalChar)
but it will have to require modifying escapedChar
function. Maybe we can catch up on this WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FranzGB LGTM! Although, I would like to understand a little bit more why this wasn't parsing the \n
before.
0f52234
to
5dff2e9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Proposed Changes
\n
and multiline strings in dotenv files.This pull request addresses issue #186. I wasn't sure if we should parse it as a newline or as a literal string. I decided to go with the latter. But happy to change it if needed. Let me know if you have any feedback.
Additionally, I noticed that our current tests depend heavily on the index of parsed (key, value) pairs, which could make them fragile and prone to breaking with minor changes in the fixture. I propose that we refactor these tests to make them more robust and resilient to changes. I look forward to hearing your thoughts on this.