@dotenvx/dotenvx 1.24.0 → 1.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,7 +2,19 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- ## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.24.0...main)
5
+ ## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.24.2...main)
6
+
7
+ ## 1.24.2
8
+
9
+ ### Changed
10
+
11
+ * treat pre-existing expandable values as literal in `process.env` ([#450](https://github.com/dotenvx/dotenvx/pull/450))
12
+
13
+ ## 1.24.1
14
+
15
+ ### Changed
16
+
17
+ * bump `cross-spawn` to prevent potential ReDoS [CVE-2024-21538](https://github.com/advisories/ghsa-3xgq-45jj-v275) ([#449](https://github.com/dotenvx/dotenvx/pull/449))
6
18
 
7
19
  ## 1.24.0
8
20
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.24.0",
2
+ "version": "1.24.2",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a better dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -49,7 +49,7 @@ class Parse {
49
49
  }
50
50
 
51
51
  // expand empty, double, or backticks
52
- if (quote !== "'") {
52
+ if (quote !== "'" && !this.processEnv[key]) {
53
53
  this.parsed[key] = resolveEscapeSequences(this.expand(this.parsed[key]))
54
54
  }
55
55
 
@@ -141,11 +141,8 @@ class Parse {
141
141
 
142
142
  let result = value
143
143
  let match
144
- const seen = new Set() // self-referential checker
145
144
 
146
145
  while ((match = regex.exec(result)) !== null) {
147
- seen.add(result)
148
-
149
146
  const [template, bracedExpression, unbracedExpression] = match
150
147
  const expression = bracedExpression || unbracedExpression
151
148
 
@@ -157,31 +154,30 @@ class Parse {
157
154
 
158
155
  const r = expression.split(splitter)
159
156
 
160
- let key
161
157
  let defaultValue
162
158
  let value
163
159
 
160
+ const key = r.shift()
161
+
164
162
  if ([':+', '+'].includes(splitter)) {
165
- key = r.shift()
166
163
  defaultValue = env[key] ? r.join(splitter) : ''
167
164
  value = null
168
165
  } else {
169
- key = r.shift()
170
166
  defaultValue = r.join(splitter)
171
167
  value = env[key]
172
168
  }
173
169
 
174
170
  if (value) {
175
- // self-referential check
176
- if (seen.has(value)) {
177
- result = result.replace(template, defaultValue)
178
- } else {
179
- result = result.replace(template, value)
180
- }
171
+ result = result.replace(template, value)
181
172
  } else {
182
173
  result = result.replace(template, defaultValue)
183
174
  }
184
175
 
176
+ // if the result equaled what was in env then stop expanding - handle self-referential check as well
177
+ if (result === env[key]) {
178
+ break
179
+ }
180
+
185
181
  regex.lastIndex = 0 // reset regex search position to re-evaluate after each replacement
186
182
  }
187
183