Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
, __call__ : function(value) {
try {
RegexValidator.prototype.__call__.call(this, value)
}
catch (e) {
if (!(e instanceof ValidationError) ||
!value ||
value.indexOf('@') == -1) {
throw e
}
// Trivial case failed - try for possible IDN domain-part
var parts = value.split('@')
try {
parts[parts.length - 1] = punycode.toASCII(parts[parts.length - 1])
}
catch (ue) {
throw e
}
RegexValidator.prototype.__call__.call(this, parts.join('@'))
}
}
})
function canonicalDomain(str) {
if (str == null) {
return null;
}
str = str.trim().replace(/^\./, ""); // S4.1.2.3 & S5.2.3: ignore leading .
// convert to IDN if any non-ASCII characters
if (punycode && /[^\u0001-\u007f]/.test(str)) {
str = punycode.toASCII(str);
}
return str.toLowerCase();
}
}
}
if (this.hostname.length > hostnameMaxLen) {
this.hostname = '';
} else {
// hostnames are always lower case.
this.hostname = this.hostname.toLowerCase();
}
if (!ipv6Hostname) {
// IDNA Support: Returns a punycoded representation of "domain".
// It only converts parts of the domain name that
// have non-ASCII characters, i.e. it doesn't matter if
// you call it with a domain that already is ASCII-only.
this.hostname = punycode.toASCII(this.hostname);
}
var p = this.port ? ':' + this.port : '';
var h = this.hostname || '';
this.host = h + p;
this.href += this.host;
// strip [ and ] from the hostname
// the host field still retains them, though
if (ipv6Hostname) {
this.hostname = this.hostname.substr(1, this.hostname.length - 2);
if (rest[0] !== '/') {
rest = '/' + rest;
}
}
}
var handlePunycode = function () {
if (!/xn--/.test(domain)) {
return parsed;
}
if (parsed.domain) {
parsed.domain = Punycode.toASCII(parsed.domain);
}
if (parsed.subdomain) {
parsed.subdomain = Punycode.toASCII(parsed.subdomain);
}
return parsed;
};
function generateDKIMHeader(domainName, keySelector, headerFieldNames, headers, body) {
var canonicalizedBody = DKIMCanonicalizer.relaxedBody(body),
canonicalizedBodyHash = sha256(canonicalizedBody, 'base64'),
canonicalizedHeaderData = DKIMCanonicalizer.relaxedHeaders(headers, headerFieldNames),
dkim;
if (hasUTFChars(domainName)) {
domainName = punycode.toASCII(domainName);
}
dkim = [
'v=1',
'a=rsa-sha256',
'c=relaxed/relaxed',
'd=' + domainName,
'q=dns/txt',
's=' + keySelector,
'bh=' + canonicalizedBodyHash,
'h=' + canonicalizedHeaderData.fieldNames
].join('; ');
return libmime.foldLines('DKIM-Signature: ' + dkim, 76) + ';\r\n b=';
}
getPunycodeUrl: function (url) {
try {
const parsed = urlParse(url)
parsed.hostname = punycode.toASCII(parsed.hostname)
return urlFormat(parsed)
} catch (e) {
return url
}
},
serialize: function (mailtoComponents, options) {
const components = mailtoComponents;
const to = toArray(mailtoComponents.to);
if (to) {
for (let x = 0, xl = to.length; x < xl; ++x) {
const toAddr = String(to[x]);
const atIdx = toAddr.lastIndexOf("@");
const localPart = (toAddr.slice(0, atIdx)).replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_LOCAL_PART, pctEncChar);
let domain = toAddr.slice(atIdx + 1);
//convert IDN via punycode
try {
domain = (!options.iri ? punycode.toASCII(unescapeComponent(domain, options).toLowerCase()) : punycode.toUnicode(domain));
}
catch (e) {
components.error = components.error || "Email address's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
}
to[x] = localPart + "@" + domain;
}
components.path = to.join(",");
}
const headers = mailtoComponents.headers = mailtoComponents.headers || {};
if (mailtoComponents.subject)
headers["subject"] = mailtoComponents.subject;
if (mailtoComponents.body)
headers["body"] = mailtoComponents.body;
const fields = [];
for (const name in headers) {
if (headers[name] !== O[name]) {
function usingPunycode(val) {
punycode.toUnicode(punycode.toASCII(val));
}
executeForHostname(cb) {
dns.lookup(punycode.toASCII(this.options.host), { all: true }, (err, addresses) => {
if (err) {
return cb(err);
}
if (this.multiSubnetFailover) {
new ParallelConnectionStrategy(addresses, this.options).connect(cb);
} else {
new SequentialConnectionStrategy(addresses, this.options).connect(cb);
}
});
}
}