Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'address-rfc2822' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
// If From has a single address, we're done
if (addrs.length === 1 && addrs[0].host) {
let fromHost = addrs[0].host();
if (fromHost) {
// don't attempt to lower a null or undefined value #1575
fromHost = fromHost.toLowerCase();
}
return fromHost;
}
// If From has multiple-addresses, we must parse and
// use the domain in the Sender header.
const sender = txn.header.get_decoded('Sender');
if (sender) {
try {
domain = (addrparser.parse(sender))[0].host().toLowerCase();
}
catch (e) {
connection.logerror(plugin, e);
}
}
return domain;
}
connection.logerror(plugin, e);
}
}
if (!txn.header) return domain;
// the DKIM signing key should be aligned with the domain in the From
// header (see DMARC). Try to parse the domain from there.
const from_hdr = txn.header.get_decoded('From');
if (!from_hdr) return domain;
// The From header can contain multiple addresses and should be
// parsed as described in RFC 2822 3.6.2.
let addrs;
try {
addrs = addrparser.parse(from_hdr);
}
catch (e) {
connection.logerror(plugin, `address-rfc2822 failed to parse From header: ${from_hdr}`)
return domain;
}
if (!addrs || ! addrs.length) return domain;
// If From has a single address, we're done
if (addrs.length === 1 && addrs[0].host) {
let fromHost = addrs[0].host();
if (fromHost) {
// don't attempt to lower a null or undefined value #1575
fromHost = fromHost.toLowerCase();
}
return fromHost;
}
exports.data_any = function (next, connection) {
var plugin = this;
if (!plugin.cfg.check.data && !plugin.cfg.check.any) {
connection.transaction.results.add(plugin, {skip: 'data(disabled)'});
return next();
}
var hdr_from = connection.transaction.header.get('From');
if (!hdr_from) {
connection.transaction.results.add(plugin, {
fail: 'data(missing_from)'});
return next();
}
var hdr_addr = haddr.parse(hdr_from)[0];
if (!hdr_addr) {
connection.transaction.results.add(plugin, {
fail: 'data(unparsable_from)'
});
return next();
}
var hdr_dom = tlds.get_organizational_domain(hdr_addr.host());
var file = plugin.cfg.domain.any;
if (plugin.in_list('domain', 'any', '!'+hdr_dom)) {
connection.results.add(plugin, {
pass: file, whitelist: true, emit: true});
return next();
}
if (plugin.in_list('domain', 'any', hdr_dom)) {
username() {
let attrs = addrparser.parse(this.email());
return attrs.user();
},
email() {
export const parseEmailAddress = (emails) => {
emails = purgeEmails(emails);
let result;
try {
result = emailParser.parse(emails);
} catch (e) {
emails = formatAddress(emails);
result = emailParser.parse(emails);
}
return result;
};
const _parseAddressValue = (value, quiet = false) => {
let parsed
try {
parsed = address.parse(value)[0]
} catch (err) {
debug('Error parsing address', value, err)
if (quiet) {
parsed = {}
} else {
throw err
}
}
parsed.raw = value
return parsed
}
export const parseEmailAddress = (emails) => {
emails = purgeEmails(emails);
let result;
try {
result = emailParser.parse(emails);
} catch (e) {
emails = formatAddress(emails);
result = emailParser.parse(emails);
}
return result;
};