Marco Ippolito
59272da055
src: swap dotenv and config file parsing order
...
Signed-off-by: Marco Ippolito <marcoippolito54@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/63035
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2026-05-04 06:39:18 +00:00
James M Snell
10df38a38b
src: improve performance of dotenv ToObject
...
Improves the performance of the dotenv parser
ToObject method. Also, switch to a null prototype
object to avoid potential prototype pollution
issues.
PR-URL: https://github.com/nodejs/node/pull/60038
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2025-10-04 12:54:47 +00:00
Daniel Lemire
2e9e844d99
src: use ranges library (C++20) more systematically
...
PR-URL: https://github.com/nodejs/node/pull/58028
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Vladimir Morozov <vmorozov@microsoft.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: Shelley Vohr <shelley.vohr@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2025-06-26 02:31:52 +00:00
Mert Can Altin
0c6e16bc84
src: env_vars caching and local variable scope optimization
...
PR-URL: https://github.com/nodejs/node/pull/57624
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-06-06 23:30:10 +00:00
Augustin Mauroy
64d9b7c5f8
util: fix parseEnv handling of invalid lines
...
PR-URL: https://github.com/nodejs/node/pull/57798
Fixes: https://github.com/nodejs/node/issues/56775
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
2025-04-21 06:46:44 +00:00
HEESEUNG
e6a0d77d57
util: fix parseEnv incorrectly splitting multiple ‘=‘ in value
...
Previously, parseEnv would create multiple environment
variables if a single line contained multiple ‘=‘ characters
(e.g. A=B=C would become { A: ‘B=C’, B: ‘C’ }).
This commit ensures that only the first ‘=‘ is used as
the key-value delimiter, and the rest of the line is treated
as the value.
Fixes: https://github.com/nodejs/node/issues/57411
PR-URL: https://github.com/nodejs/node/pull/57421
Reviewed-By: Daniel Lemire <daniel@lemire.me >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2025-04-06 07:47:28 +00:00
James M Snell
e03af77418
src: improve error handling in buffer and dotenv
...
Replacing ToLocalChecked()
PR-URL: https://github.com/nodejs/node/pull/57189
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Robert Nagy <ronagy@icloud.com >
2025-02-25 16:41:10 -08:00
Cheng
1d8593e3b1
src: fix accessing empty string
...
PR-URL: https://github.com/nodejs/node/pull/57014
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-02-16 06:45:40 +00:00
Dario Piotrowicz and Yagiz Nizipli
43ffcf1d2e
src: improve node::Dotenv trimming
...
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 <yagiz@nizipli.com >
PR-URL: https://github.com/nodejs/node/pull/56983
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-02-11 22:26:51 +00:00
Shima Ryuhei
3bb1d28499
src: safely remove the last line from dotenv
...
Refs: https://github.com/nodejs/node/issues/55925
PR-URL: https://github.com/nodejs/node/pull/55982
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Richard Lau <rlau@redhat.com >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
2024-11-26 10:12:50 +00:00
Bosco Domingo
53ede878a5
src: add --env-file-if-exists flag
...
Fixes: https://github.com/nodejs/node/issues/50993
Refs: https://github.com/nodejs/node/issues/51451
test: remove unnecessary comment
src: conform to style guidelines
src: change flag to `--env-file-optional`
test: revert automatic linter changes
doc: fix typos
src: change flag to `--env-file-if-exists`
src: refactor `env_file_data` and `GetEnvFileDataFromArgs`
test: clean up tests
src: print error when file not found
test: remove unnecessary extras
PR-URL: https://github.com/nodejs/node/pull/53060
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2024-09-16 00:58:16 +00:00
Michaël Zasso
8f1fa03c13
src: use better return types in KVStore
...
- Use `v8::Maybe<void>` instead of `v8::Maybe<bool>` and handle error
from `AssignFromObject`.
- An empty `v8::Maybe` is supposed to be returned when an exception is
pending. Use `std::optional` instead to indicate a missing value in
`Get(key)`.
PR-URL: https://github.com/nodejs/node/pull/54539
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
2024-08-26 15:33:35 +02:00
Aviv Keller and Cedric Staniewski
880c446d95
src: don't match after -- in Dotenv::GetPathFromArgs
...
Co-Authored-By: Cedric Staniewski <cedric@gmx.ca >
PR-URL: https://github.com/nodejs/node/pull/54237
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2024-08-13 23:56:56 +00:00
Mohit Malhotra
aca49fc7d1
src: fix env-file flag to ignore spaces before quotes
...
Fix to ignore spaces between '=' and quoted string in env file
Fixes: https://github.com/nodejs/node/issues/53461
Signed-off-by: Mohit Malhotra <dev.mohitmalhotra@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/53786
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
2024-07-17 09:22:42 +00:00
Yagiz Nizipli
25719b11a0
src: use starts_with in node_dotenv.cc
...
PR-URL: https://github.com/nodejs/node/pull/53539
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2024-06-25 09:41:33 +00:00
Tobias Nießen
3f3226c8e3
src: improve node::Dotenv declarations
...
There is no need to explicitly allow copy constructor and copy
assignment, and some of these functions should be marked as const.
PR-URL: https://github.com/nodejs/node/pull/52973
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2024-05-16 19:33:17 +00:00
IlyasShabi
3f88e149a9
src: remove regex usage for env file parsing
...
PR-URL: https://github.com/nodejs/node/pull/52406
Fixes: https://github.com/nodejs/node/issues/52248
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io >
2024-04-17 05:30:05 +00:00
Cheng Zhao
c682fbfbe2
src: check empty before accessing string
...
Fix an assertion when running dotnev tests with GN build:
assertion !empty() failed: string::front(): string is empty
which was caused by calling value.front() without verifying the value is
not empty.
PR-URL: https://github.com/nodejs/node/pull/51665
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
2024-02-16 14:33:37 +00:00
IlyasShabi
8b2836611e
src: support multi-line values for .env file
...
PR-URL: https://github.com/nodejs/node/pull/51289
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io >
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
2024-01-31 13:09:13 +00:00
Yagiz Nizipli
0056147a87
src: add process.loadEnvFile and util.parseEnv
...
PR-URL: https://github.com/nodejs/node/pull/51476
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
2024-01-23 18:46:26 +00:00
Marco Ippolito
880c90c873
src: terminate correctly double-quote in env variable
...
PR-URL: https://github.com/nodejs/node/pull/51510
Fixes: https://github.com/nodejs/node/issues/51508
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io >
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2024-01-20 09:44:13 +00:00
Ardi Nugraha
996d198101
src: return error --env-file if file is not found
...
PR-URL: https://github.com/nodejs/node/pull/50588
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2023-11-14 04:05:57 +00:00
Yagiz Nizipli
ce30b4ea40
src: support multiple --env-file declarations
...
PR-URL: https://github.com/nodejs/node/pull/49542
Refs: https://github.com/nodejs/node/issues/49148
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
2023-09-10 03:44:37 +00:00
Phil Nash
015e27bd08
src: don't overwrite environment from .env file
...
This commit adds a check to see if an environment variable that is
found in the .env file is already set in the environment. If it is,
then the value from the .env file is not used.
PR-URL: https://github.com/nodejs/node/pull/49424
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
2023-09-08 06:44:36 +00:00
Yagiz Nizipli
769823e57c
src: add built-in .env file support
...
PR-URL: https://github.com/nodejs/node/pull/48890
Refs: https://github.com/orgs/nodejs/discussions/44975
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Paolo Insogna <paolo@cowtech.it >
2023-08-17 14:08:05 +00:00