mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2026-11-21 21:06:12 +07:00
node_modules: update (#362)
Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
This commit is contained in:
1 parent
4a48500d96
commit
aefdaa6a6c
49 files changed
+1316
-295
No files matched your search
+1
-73
@@ -1,10 +1,8 @@
|
||||
/* eslint no-undefined: 0, prefer-spread: 0, no-control-regex: 0 */
|
||||
import crypto from 'node:crypto';
|
||||
import fs from 'node:fs';
|
||||
import * as punycode from '../punycode/index.js';
|
||||
import { PassThrough, finished, pipeline } from 'node:stream';
|
||||
import * as shared from '../shared/index.js';
|
||||
import urlModule from 'node:url';
|
||||
import * as mimeFuncs from '../mime-funcs/index.js';
|
||||
import * as qp from '../qp/index.js';
|
||||
import * as base64 from '../base64/index.js';
|
||||
@@ -55,20 +53,6 @@ function stripWhitespaceInAngleBrackets(value) {
|
||||
}
|
||||
return result + value.slice(pos);
|
||||
}
|
||||
// domainToASCII and domainToUnicode are WHATWG host parsers rather than plain IDNA
|
||||
// mappers, so they do more than map: they cut the host at '/', '\\', '?' and '#', drop C0
|
||||
// controls, and percent-decode. Handing them 'evil.example/mail.corp.example' returns the
|
||||
// deliverable 'evil.example', which would turn a value the bundled codec leaves as
|
||||
// unroutable garbage into mail for a domain the sender never named. None of these
|
||||
// characters are legal in a domain, so keep them away from the mapper.
|
||||
const URL_PARSER_UNSAFE = /[/\\?#%\x00-\x20\x7F]/;
|
||||
// RFC 1035 bounds a label at 63 octets and a domain at 253. An A-label is never shorter than
|
||||
// the code points it encodes, so anything past these bounds could not have become a valid
|
||||
// domain whichever way it is encoded. The bundled codec is super-linear in the length of a
|
||||
// label, a 60 KB label of distinct code points took seconds to encode, several times per
|
||||
// address, so it is only handed what could be a domain
|
||||
const MAX_DOMAIN_LENGTH = 253;
|
||||
const MAX_LABEL_LENGTH = 63;
|
||||
// pipeline() needs a callback to not throw, the errors it sees reach the last stream anyway
|
||||
const PIPELINE_NOOP = () => false;
|
||||
// The error a node streaming into an output that was destroyed stops with
|
||||
@@ -77,62 +61,6 @@ function abortedError() {
|
||||
err.code = errors.ESTREAM;
|
||||
return err;
|
||||
}
|
||||
/**
|
||||
* Checks a domain against the DNS length limits, counted in code points per label and in
|
||||
* total. The label separators are the ones the bundled codec splits on.
|
||||
*
|
||||
* @param domain Domain to check
|
||||
* @return true if a label or the domain as a whole is too long to be a valid domain
|
||||
*/
|
||||
function exceedsDomainLimits(domain) {
|
||||
let total = 0;
|
||||
let label = 0;
|
||||
for (const char of domain) {
|
||||
total++;
|
||||
if (char === '.' || char === '。' || char === '.' || char === '。') {
|
||||
label = 0;
|
||||
}
|
||||
else if (++label > MAX_LABEL_LENGTH) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return total > MAX_DOMAIN_LENGTH;
|
||||
}
|
||||
/**
|
||||
* Encodes a domain the way browsers, the WHATWG URL Standard and DNS facing resolvers do,
|
||||
* which is with UTS-46 mapping applied before the Punycode step.
|
||||
*
|
||||
* The bundled codec is plain RFC 3492 and maps nothing, so it disagrees with every
|
||||
* conformant parser on any domain holding a mapped or ignored code point. An invisible
|
||||
* U+00AD in 'compa\u00ADny.com' encoded to 'xn--company-pka.com' where a validator reads
|
||||
* 'company.com', which let an allow-listed domain be checked and a different one mailed.
|
||||
*
|
||||
* Anything the URL parser does not accept as a hostname, an address literal such as
|
||||
* '[127.0.0.1]' included, comes back empty and falls through to the bundled codec, which
|
||||
* leaves those as they were supplied.
|
||||
*
|
||||
* @param domain Domain to encode, already lowercased by the caller
|
||||
* @param toUnicode Return the U-label form instead of the A-label form
|
||||
* @return Encoded domain
|
||||
*/
|
||||
function normalizeDomain(domain, toUnicode) {
|
||||
// domainToASCII and domainToUnicode landed in Node 7, the bundled codec covers Node 6
|
||||
if (typeof urlModule.domainToASCII === 'function' && typeof urlModule.domainToUnicode === 'function' && !URL_PARSER_UNSAFE.test(domain)) {
|
||||
// The U-label form is decoded from the A-label form rather than from the input:
|
||||
// Deno's domainToASCII returns an empty string for a label it cannot decode, while
|
||||
// its domainToUnicode returns the label with U+FFFD in place of the bad part
|
||||
const ascii = urlModule.domainToASCII(domain);
|
||||
const mapped = ascii && toUnicode ? urlModule.domainToUnicode(ascii) : ascii;
|
||||
if (mapped) {
|
||||
return mapped;
|
||||
}
|
||||
}
|
||||
if (exceedsDomainLimits(domain)) {
|
||||
// too long to be a domain whichever way it is encoded, keep it as supplied
|
||||
return domain;
|
||||
}
|
||||
return toUnicode ? punycode.toUnicode(domain) : punycode.toASCII(domain);
|
||||
}
|
||||
/**
|
||||
* Removes the characters that must never reach a multipart delimiter line.
|
||||
*
|
||||
@@ -1500,7 +1428,7 @@ class MimeNode {
|
||||
// symmetry on both sides of the '@' rather than being encoded to an A-label
|
||||
const smtputf8 = /[\x80-\uFFFF]/.test(user);
|
||||
try {
|
||||
encodedDomain = normalizeDomain(domain.toLowerCase(), smtputf8);
|
||||
encodedDomain = shared.normalizeDomain(domain, smtputf8);
|
||||
}
|
||||
catch (_err) {
|
||||
// keep domain as supplied
|
||||
|
||||
Reference in new issue
Block a user