pnpm 11.2.2 → 11.4.0

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.
@@ -98,6 +98,9 @@ class Range {
98
98
  }
99
99
 
100
100
  parseRange (range) {
101
+ // strip build metadata so it can't bleed into the version
102
+ range = range.replace(BUILDSTRIPRE, '')
103
+
101
104
  // memoize range parsing for performance.
102
105
  // this is a very hot path, and fully deterministic.
103
106
  const memoOpts =
@@ -223,6 +226,7 @@ const debug = require('../internal/debug')
223
226
  const SemVer = require('./semver')
224
227
  const {
225
228
  safeRe: re,
229
+ src,
226
230
  t,
227
231
  comparatorTrimReplace,
228
232
  tildeTrimReplace,
@@ -230,6 +234,9 @@ const {
230
234
  } = require('../internal/re')
231
235
  const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require('../internal/constants')
232
236
 
237
+ // unbounded global build-metadata stripper used by parseRange
238
+ const BUILDSTRIPRE = new RegExp(src[t.BUILD], 'g')
239
+
233
240
  const isNullSet = c => c.value === '<0.0.0-0'
234
241
  const isAny = c => c.value === ''
235
242
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semver",
3
- "version": "7.8.0",
3
+ "version": "7.8.1",
4
4
  "description": "The semantic version parser used by npm.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -174,7 +174,7 @@ const simpleSubset = (sub, dom, options) => {
174
174
  if (higher === c && higher !== gt) {
175
175
  return false
176
176
  }
177
- } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) {
177
+ } else if (gt.operator === '>=' && !c.test(gt.semver)) {
178
178
  return false
179
179
  }
180
180
  }
@@ -192,7 +192,7 @@ const simpleSubset = (sub, dom, options) => {
192
192
  if (lower === c && lower !== lt) {
193
193
  return false
194
194
  }
195
- } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) {
195
+ } else if (lt.operator === '<=' && !c.test(lt.semver)) {
196
196
  return false
197
197
  }
198
198
  }
@@ -24,7 +24,6 @@ function defaultFactory (origin, opts) {
24
24
 
25
25
  class Agent extends DispatcherBase {
26
26
  constructor ({ factory = defaultFactory, maxRedirections = 0, connect, ...options } = {}) {
27
-
28
27
  if (typeof factory !== 'function') {
29
28
  throw new InvalidArgumentError('factory must be a function.')
30
29
  }
@@ -279,29 +279,71 @@ class Parser {
279
279
 
280
280
  const offset = llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr
281
281
 
282
- if (ret === constants.ERROR.PAUSED_UPGRADE) {
283
- this.onUpgrade(data.slice(offset))
284
- } else if (ret === constants.ERROR.PAUSED) {
285
- this.paused = true
286
- socket.unshift(data.slice(offset))
287
- } else if (ret !== constants.ERROR.OK) {
288
- const ptr = llhttp.llhttp_get_error_reason(this.ptr)
289
- let message = ''
290
- /* istanbul ignore else: difficult to make a test case for */
291
- if (ptr) {
292
- const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
293
- message =
294
- 'Response does not match the HTTP/1.1 protocol (' +
295
- Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
296
- ')'
282
+ if (ret !== constants.ERROR.OK) {
283
+ const body = data.subarray(offset)
284
+
285
+ if (ret === constants.ERROR.PAUSED_UPGRADE) {
286
+ this.onUpgrade(body)
287
+ } else if (ret === constants.ERROR.PAUSED) {
288
+ this.paused = true
289
+ socket.unshift(body)
290
+ } else {
291
+ throw this.createError(ret, body)
297
292
  }
298
- throw new HTTPParserError(message, constants.ERROR[ret], data.slice(offset))
299
293
  }
300
294
  } catch (err) {
301
295
  util.destroy(socket, err)
302
296
  }
303
297
  }
304
298
 
299
+ finish () {
300
+ assert(currentParser === null)
301
+ assert(this.ptr != null)
302
+ assert(!this.paused)
303
+
304
+ const { llhttp } = this
305
+
306
+ let ret
307
+
308
+ try {
309
+ currentParser = this
310
+ ret = llhttp.llhttp_finish(this.ptr)
311
+ } finally {
312
+ currentParser = null
313
+ }
314
+
315
+ if (ret === constants.ERROR.OK) {
316
+ return null
317
+ }
318
+
319
+ if (ret === constants.ERROR.PAUSED || ret === constants.ERROR.PAUSED_UPGRADE) {
320
+ this.paused = true
321
+ return null
322
+ }
323
+
324
+ return this.createError(ret, EMPTY_BUF)
325
+ }
326
+
327
+ createError (ret, data) {
328
+ const { llhttp, contentLength, bytesRead } = this
329
+
330
+ if (contentLength && bytesRead !== parseInt(contentLength, 10)) {
331
+ return new ResponseContentLengthMismatchError()
332
+ }
333
+
334
+ const ptr = llhttp.llhttp_get_error_reason(this.ptr)
335
+ let message = ''
336
+ if (ptr) {
337
+ const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
338
+ message =
339
+ 'Response does not match the HTTP/1.1 protocol (' +
340
+ Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
341
+ ')'
342
+ }
343
+
344
+ return new HTTPParserError(message, constants.ERROR[ret], data)
345
+ }
346
+
305
347
  destroy () {
306
348
  assert(this.ptr != null)
307
349
  assert(currentParser == null)
@@ -673,8 +715,11 @@ async function connectH1 (client, socket) {
673
715
  // On Mac OS, we get an ECONNRESET even if there is a full body to be forwarded
674
716
  // to the user.
675
717
  if (err.code === 'ECONNRESET' && parser.statusCode && !parser.shouldKeepAlive) {
676
- // We treat all incoming data so for as a valid response.
677
- parser.onMessageComplete()
718
+ const parserErr = parser.finish()
719
+ if (parserErr) {
720
+ this[kError] = parserErr
721
+ this[kClient][kOnError](parserErr)
722
+ }
678
723
  return
679
724
  }
680
725
 
@@ -693,8 +738,10 @@ async function connectH1 (client, socket) {
693
738
  const parser = this[kParser]
694
739
 
695
740
  if (parser.statusCode && !parser.shouldKeepAlive) {
696
- // We treat all incoming data so far as a valid response.
697
- parser.onMessageComplete()
741
+ const parserErr = parser.finish()
742
+ if (parserErr) {
743
+ util.destroy(this, parserErr)
744
+ }
698
745
  return
699
746
  }
700
747
 
@@ -706,8 +753,7 @@ async function connectH1 (client, socket) {
706
753
 
707
754
  if (parser) {
708
755
  if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) {
709
- // We treat all incoming data so far as a valid response.
710
- parser.onMessageComplete()
756
+ this[kError] = parser.finish() || this[kError]
711
757
  }
712
758
 
713
759
  this[kParser].destroy()
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "undici",
3
- "version": "6.25.0",
3
+ "version": "6.26.0",
4
4
  "description": "An HTTP/1.1 client, written from scratch for Node.js",
5
5
  "homepage": "https://undici.nodejs.org",
6
6
  "bugs": {