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
94 changes: 88 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13825,7 +13825,11 @@ var require_request = __commonJS({
} else if (typeof val[i] === "object") {
throw new InvalidArgumentError(`invalid ${key} header`);
} else {
arr.push(`${val[i]}`);
const str = `${val[i]}`;
if (!isValidHeaderValue(str)) {
throw new InvalidArgumentError(`invalid ${key} header`);
}
arr.push(str);
}
}
val = arr;
Expand All @@ -13837,6 +13841,9 @@ var require_request = __commonJS({
val = "";
} else {
val = `${val}`;
if (!isValidHeaderValue(val)) {
throw new InvalidArgumentError(`invalid ${key} header`);
}
}
if (headerName === "host") {
if (request2.host !== null) {
Expand Down Expand Up @@ -17567,6 +17574,7 @@ var require_client_h1 = __commonJS({
RequestContentLengthMismatchError,
ResponseContentLengthMismatchError,
RequestAbortedError,
InvalidArgumentError,
HeadersTimeoutError,
HeadersOverflowError,
SocketError,
Expand Down Expand Up @@ -18293,8 +18301,16 @@ var require_client_h1 = __commonJS({
}
body = bodyStream.stream;
contentLength = bodyStream.length;
} else if (util4.isBlobLike(body) && request2.contentType == null && body.type) {
headers.push("content-type", body.type);
} else if (util4.isBlobLike(body) && request2.contentType == null) {
const contentType = body.type;
if (contentType) {
const contentTypeValue = `${contentType}`;
if (!util4.isValidHeaderValue(contentTypeValue)) {
util4.errorRequest(client, request2, new InvalidArgumentError("invalid content-type header"));
return false;
}
headers.push("content-type", contentTypeValue);
}
}
if (body && typeof body.read === "function") {
body.read(0);
Expand Down Expand Up @@ -20846,6 +20862,24 @@ var require_retry_handler = __commonJS({
const current = Date.now();
return new Date(retryAfter).getTime() - current;
}
function validatePartialResponseContentLength(headers, range, statusCode, retryCount) {
const contentLength = headers["content-length"];
if (contentLength == null) {
return null;
}
if (!Number.isFinite(range.start) || !Number.isFinite(range.end)) {
return null;
}
const length = Number(contentLength);
const expectedLength = range.end - range.start + 1;
if (!Number.isFinite(length) || length !== expectedLength) {
return new RequestRetryError("Content-Length mismatch", statusCode, {
headers,
data: { count: retryCount }
});
}
return null;
}
var RetryHandler = class _RetryHandler {
constructor(opts, handlers) {
const { retryOptions, ...dispatchOpts } = opts;
Expand Down Expand Up @@ -21018,6 +21052,11 @@ var require_retry_handler = __commonJS({
);
return false;
}
const contentLengthError = validatePartialResponseContentLength(headers, contentRange, statusCode, this.retryCount);
if (contentLengthError != null) {
this.abort(contentLengthError);
return false;
}
const { start, size, end = size - 1 } = contentRange;
assert(this.start === start, "content-range mismatch");
assert(this.end == null || this.end === end, "content-range mismatch");
Expand All @@ -21035,6 +21074,11 @@ var require_retry_handler = __commonJS({
statusMessage
);
}
const contentLengthError = validatePartialResponseContentLength(headers, range, statusCode, this.retryCount);
if (contentLengthError != null) {
this.abort(contentLengthError);
return false;
}
const { start, size, end = size - 1 } = range;
assert(
start != null && Number.isFinite(start),
Expand Down Expand Up @@ -27880,14 +27924,48 @@ var require_util6 = __commonJS({
for (let i = 0; i < path.length; ++i) {
const code = path.charCodeAt(i);
if (code < 32 || // exclude CTLs (0-31)
code === 127 || // DEL
code > 126 || // exclude DEL and non-ascii
code === 59) {
throw new Error("Invalid cookie path");
}
}
}
function isLetterOrDigit(code) {
return code >= 48 && code <= 57 || // 0-9
code >= 65 && code <= 90 || // A-Z
code >= 97 && code <= 122;
}
function validateCookieDomain(domain) {
if (domain.startsWith("-") || domain.endsWith(".") || domain.endsWith("-")) {
if (domain === " ") {
return;
}
if (domain.length > 255) {
throw new Error("Invalid cookie domain");
}
let labelLength = 0;
for (let i = 0; i < domain.length; ++i) {
const code = domain.charCodeAt(i);
if (code === 46) {
if (labelLength === 0) {
throw new Error("Invalid cookie domain");
}
if (domain.charCodeAt(i - 1) === 45) {
throw new Error("Invalid cookie domain");
}
labelLength = 0;
continue;
}
if (labelLength === 0 && !isLetterOrDigit(code)) {
throw new Error("Invalid cookie domain");
}
if (!isLetterOrDigit(code) && code !== 45) {
throw new Error("Invalid cookie domain");
}
if (++labelLength > 63) {
throw new Error("Invalid cookie domain");
}
}
if (labelLength === 0 || domain.charCodeAt(domain.length - 1) === 45) {
throw new Error("Invalid cookie domain");
}
}
Expand Down Expand Up @@ -27970,7 +28048,11 @@ var require_util6 = __commonJS({
throw new Error("Invalid unparsed");
}
const [key, ...value] = part.split("=");
out.push(`${key.trim()}=${value.join("=")}`);
const trimmedKey = key.trim();
const joinedValue = value.join("=");
validateCookieName(trimmedKey);
validateCookieValue(joinedValue);
out.push(`${trimmedKey}=${joinedValue}`);
}
return out.join("; ");
}
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading