-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
src: improve node::Dotenv trimming #56983
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
src: improve node::Dotenv trimming #56983
Conversation
3dba125
to
ff0ffe4
Compare
b5dd12f
to
00d9449
Compare
Looking good. After these changes, we can land this pull-request. @dario-piotrowicz |
1eb6236
to
eabaf64
Compare
the trimming functionality that the dotenv parsing uses currently only takes into consideration plain spaces (' '), other type of space characters such as tabs and newlines are not trimmed, this can cause subtle bugs, so the changes here make sure that such characters get trimmed as well Co-authored-by: Yagiz Nizipli <[email protected]>
eabaf64
to
47d1a76
Compare
@anonrig thank you very much for your review and help here 🙏 (and sorry for the silly mistakes 😓) I've applied all your suggested changes 🙂 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #56983 +/- ##
==========================================
- Coverage 89.13% 89.13% -0.01%
==========================================
Files 665 665
Lines 193167 193177 +10
Branches 37190 37193 +3
==========================================
+ Hits 172185 172192 +7
- Misses 13731 13743 +12
+ Partials 7251 7242 -9
|
@dario-piotrowicz the tests are failing |
remove pos_start == pos_end check
Sorry about that, I've addressed it 🙂 (e3ee074) The issue was this new check: if (pos_start == pos_end) {
return "";
} since if I removed the check completely (instead of returning do you agree? PS: that's not the only issue 🤔 |
add check for when no value is present
6d32733
to
c261fb4
Compare
if (input.front() == ' ') { | ||
input.remove_prefix(input.find_first_not_of(' ')); | ||
|
||
auto pos_start = input.find_first_not_of(" \t\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.
should this also include \r
and \f
?
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.
sounds good to me 🙂, but I'm not sure how to test that, would you be ok with addition without dedicated tests for it?
Landed in 43ffcf1 |
the trimming functionality that the dotenv parsing uses currently only takes into consideration plain spaces (' '), other type of space characters such as tabs and newlines are not trimmed, this can cause subtle bugs, so the changes here make sure that such characters get trimmed as well Co-authored-by: Yagiz Nizipli <[email protected]> PR-URL: #56983 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]>
the trimming functionality that the dotenv parsing uses currently only takes into consideration plain spaces (' '), other type of space characters such as tabs and newlines are not trimmed, this can cause subtle bugs, so the changes here make sure that such characters get trimmed as well Co-authored-by: Yagiz Nizipli <[email protected]> PR-URL: nodejs#56983 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]>
the trimming functionality that the dotenv parsing uses currently only takes into consideration plain spaces (' '), other type of space characters such as tabs and newlines are not trimmed, this can cause subtle bugs, so the changes here make sure that such characters get trimmed as well Co-authored-by: Yagiz Nizipli <[email protected]> PR-URL: #56983 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]>
the trimming functionality that the dotenv parsing uses currently only takes into consideration plain spaces (' '), other type of space characters such as tabs and newlines are not trimmed, this can cause subtle bugs, so the changes here make sure that such characters get trimmed as well Co-authored-by: Yagiz Nizipli <[email protected]> PR-URL: #56983 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]>
the trimming functionality that the dotenv parsing uses currently only takes into consideration plain spaces (' '), other type of space characters such as tabs and newlines are not trimmed, this can cause subtle bugs, so the changes here make sure that such characters get trimmed as well Co-authored-by: Yagiz Nizipli <[email protected]> PR-URL: #56983 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]>
the trimming functionality that the dotenv parsing uses currently only takes into consideration plain spaces (' '), other type of space characters such as tabs and newlines are not trimmed, this can cause subtle bugs, so the changes here make sure that such characters get trimmed as well Co-authored-by: Yagiz Nizipli <[email protected]> PR-URL: #56983 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]>
the trimming functionality that the dotenv parsing uses currently only takes into consideration plain spaces (' '), other type of space characters such as tabs and newlines are not trimmed, this can cause subtle bugs, so the changes here make sure that such characters get trimmed as well
Fixes #56686