-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add multi-line support #63
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #63 +/- ##
==========================================
+ Coverage 86.77% 87.82% +1.04%
==========================================
Files 7 7
Lines 242 271 +29
==========================================
+ Hits 210 238 +28
- Misses 32 33 +1
Continue to review full report at Codecov.
|
86b582b
to
0e2c48b
Compare
0e2c48b
to
0b99e5b
Compare
The parser on master doesn't handle lines with unterminated For example:
So this shouldn't break anything that was previously working The implementation provided in this PR won't handle cases such as below, but I'm not sure people would expect it to
On a related note, whilst experimenting I found that the parser on master doesn't handle escapes within
|
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.
Looks great. Very reasonable solution too!
match self.buf.read_line(&mut buf) { | ||
Ok(0) => return None, | ||
Ok(_n) => { | ||
if is_complete(&buf) { |
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.
This looks to me like it would cause an exponential slowdown if a quote contained a large number of lines - it would have to loop through every character read so far for each new line.
Would it be possible to make this a stateful parser which keeps track of what quotes have been seen so far, and only looks at each character once be possible without making it significantly more complicated?
I mean, the current code won't slow down any current use cases, and env variables are unlikely to be very large. But it seems non-ideal to have an exponential slowdown if it's avoidable?
I'm asking as an observer: I don't have any ownership over dotenv.
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'll have a go at it
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.
have it working:
#78
superseded by allan2/dotenvy#3 |
dotenv appears unmaintained and [does not support multiline values](dotenv-rs/dotenv#63) yet. Replace this with a the well maintained fork [dotenvy](https://crates.io/crates/dotenvy). ## Testing Ran `scope doctor run` locally and confirmed it successfully reads multi-line env vars correctly.
Fixes #40