Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 118 additions & 11 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11756,6 +11756,18 @@ var setToStringTag = __nccwpck_require__(1770);
var hasOwn = __nccwpck_require__(2157);
var populate = __nccwpck_require__(7142);

/**
* Escape CR, LF, and `"` in a multipart `name`/`filename` parameter, so a field
* name or filename can not break out of its header line to inject headers or
* smuggle additional parts. Matches the WHATWG HTML multipart/form-data encoding.
*
* @param {string} str - the parameter value to escape
* @returns {string} the escaped value
*/
function escapeHeaderParam(str) {
return String(str).replace(/\r/g, '%0D').replace(/\n/g, '%0A').replace(/"/g, '%22');
}

/**
* Create readable "multipart/form-data" streams.
* Can be used to submit forms
Expand Down Expand Up @@ -11921,7 +11933,7 @@ FormData.prototype._multiPartHeader = function (field, value, options) {
var contents = '';
var headers = {
// add custom disposition as third element or keep it two elements if not
'Content-Disposition': ['form-data', 'name="' + field + '"'].concat(contentDisposition || []),
'Content-Disposition': ['form-data', 'name="' + escapeHeaderParam(field) + '"'].concat(contentDisposition || []),
// if no content type. allow it to be empty array
'Content-Type': [].concat(contentType || [])
};
Expand Down Expand Up @@ -11975,7 +11987,7 @@ FormData.prototype._getContentDisposition = function (value, options) { // eslin
}

if (filename) {
return 'filename="' + filename + '"';
return 'filename="' + escapeHeaderParam(filename) + '"';
}
};

Expand Down Expand Up @@ -14113,6 +14125,9 @@ class Range {
}

parseRange (range) {
// strip build metadata so it can't bleed into the version
range = range.replace(BUILDSTRIPRE, '')

// memoize range parsing for performance.
// this is a very hot path, and fully deterministic.
const memoOpts =
Expand Down Expand Up @@ -14238,13 +14253,17 @@ const debug = __nccwpck_require__(427)
const SemVer = __nccwpck_require__(8088)
const {
safeRe: re,
src,
t,
comparatorTrimReplace,
tildeTrimReplace,
caretTrimReplace,
} = __nccwpck_require__(9523)
const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = __nccwpck_require__(2293)

// unbounded global build-metadata stripper used by parseRange
const BUILDSTRIPRE = new RegExp(src[t.BUILD], 'g')

const isNullSet = c => c.value === '<0.0.0-0'
const isAny = c => c.value === ''

Expand Down Expand Up @@ -14285,6 +14304,11 @@ const parseComparator = (comp, options) => {

const isX = id => !id || id.toLowerCase() === 'x' || id === '*'

const invalidXRangeOrder = (M, m, p) => (
(isX(M) && !isX(m)) ||
(isX(m) && p && !isX(p))
)

// ~, ~> --> * (any, kinda silly)
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
Expand All @@ -14302,17 +14326,21 @@ const replaceTildes = (comp, options) => {

const replaceTilde = (comp, options) => {
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
// if we're including prereleases in the match, then the lower bound is
// -0, the lowest possible prerelease value, just like x-ranges and carets.
// this keeps `~1.2` equivalent to the `1.2.x` x-range it's documented as.
const z = options.includePrerelease ? '-0' : ''
return comp.replace(r, (_, M, m, p, pr) => {
debug('tilde', comp, _, M, m, p, pr)
let ret

if (isX(M)) {
ret = ''
} else if (isX(m)) {
ret = `>=${M}.0.0 <${+M + 1}.0.0-0`
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`
} else if (isX(p)) {
// ~1.2 == >=1.2.0 <1.3.0-0
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`
} else if (pr) {
debug('replaceTilde pr', pr)
ret = `>=${M}.${m}.${p}-${pr
Expand Down Expand Up @@ -14381,10 +14409,10 @@ const replaceCaret = (comp, options) => {
if (M === '0') {
if (m === '0') {
ret = `>=${M}.${m}.${p
}${z} <${M}.${m}.${+p + 1}-0`
} <${M}.${m}.${+p + 1}-0`
} else {
ret = `>=${M}.${m}.${p
}${z} <${M}.${+m + 1}.0-0`
} <${M}.${+m + 1}.0-0`
}
} else {
ret = `>=${M}.${m}.${p
Expand All @@ -14410,6 +14438,10 @@ const replaceXRange = (comp, options) => {
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
debug('xRange', comp, ret, gtlt, M, m, p, pr)
if (invalidXRangeOrder(M, m, p)) {
return comp
}

const xM = isX(M)
const xm = xM || isX(m)
const xp = xm || isX(p)
Expand Down Expand Up @@ -14586,6 +14618,22 @@ const { safeRe: re, t } = __nccwpck_require__(9523)

const parseOptions = __nccwpck_require__(785)
const { compareIdentifiers } = __nccwpck_require__(2463)

const isPrereleaseIdentifier = (prerelease, identifier) => {
const identifiers = identifier.split('.')
if (identifiers.length > prerelease.length) {
return false
}

for (let i = 0; i < identifiers.length; i++) {
if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) {
return false
}
}

return true
}

class SemVer {
constructor (version, options) {
options = parseOptions(options)
Expand Down Expand Up @@ -14889,8 +14937,9 @@ class SemVer {
if (identifierBase === false) {
prerelease = [identifier]
}
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
if (isNaN(this.prerelease[1])) {
if (isPrereleaseIdentifier(this.prerelease, identifier)) {
const prereleaseBase = this.prerelease[identifier.split('.').length]
if (isNaN(prereleaseBase)) {
this.prerelease = prerelease
}
} else {
Expand Down Expand Up @@ -15421,6 +15470,62 @@ const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose))
module.exports = sort


/***/ }),

/***/ 5937:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

"use strict";


const parse = __nccwpck_require__(5925)
const constants = __nccwpck_require__(2293)
const SemVer = __nccwpck_require__(8088)

const truncate = (version, truncation, options) => {
if (!constants.RELEASE_TYPES.includes(truncation)) {
return null
}

const clonedVersion = cloneInputVersion(version, options)
return clonedVersion && doTruncation(clonedVersion, truncation)
}

const cloneInputVersion = (version, options) => {
const versionStringToParse = (
version instanceof SemVer ? version.version : version
)

return parse(versionStringToParse, options)
}

const doTruncation = (version, truncation) => {
if (isPrerelease(truncation)) {
return version.version
}

version.prerelease = []

switch (truncation) {
case 'major':
version.minor = 0
version.patch = 0
break
case 'minor':
version.patch = 0
break
}

return version.format()
}

const isPrerelease = (type) => {
return type.startsWith('pre')
}

module.exports = truncate


/***/ }),

/***/ 9601:
Expand Down Expand Up @@ -15473,6 +15578,7 @@ const gte = __nccwpck_require__(5522)
const lte = __nccwpck_require__(7520)
const cmp = __nccwpck_require__(5098)
const coerce = __nccwpck_require__(3466)
const truncate = __nccwpck_require__(5937)
const Comparator = __nccwpck_require__(1532)
const Range = __nccwpck_require__(9828)
const satisfies = __nccwpck_require__(6055)
Expand Down Expand Up @@ -15511,6 +15617,7 @@ module.exports = {
lte,
cmp,
coerce,
truncate,
Comparator,
Range,
satisfies,
Expand Down Expand Up @@ -15856,7 +15963,7 @@ createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`)
createToken('GTLT', '((?:<|>)?=?)')

// Something like "2.*" or "1.2.x".
// Note that "x.x" is a valid xRange identifer, meaning "any version"
// Note that "x.x" is a valid xRange identifier, meaning "any version"
// Only the first item is strictly required.
createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`)
createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`)
Expand Down Expand Up @@ -16457,7 +16564,7 @@ const simpleSubset = (sub, dom, options) => {
if (higher === c && higher !== gt) {
return false
}
} else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) {
} else if (gt.operator === '>=' && !c.test(gt.semver)) {
return false
}
}
Expand All @@ -16475,7 +16582,7 @@ const simpleSubset = (sub, dom, options) => {
if (lower === c && lower !== lt) {
return false
}
} else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) {
} else if (lt.operator === '<=' && !c.test(lt.semver)) {
return false
}
}
Expand Down
Loading
Loading