fix(Email Trigger (IMAP) Node): Fix connection issue with unexpected spaces in host (#6886)

This commit is contained in:
Jon 2023-08-10 08:58:51 +01:00 committed by GitHub
parent 718e61354d
commit f3248e46e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 16 deletions

View file

@ -241,7 +241,7 @@ export class EmailReadImapV1 implements INodeType {
imap: { imap: {
user: credentials.user as string, user: credentials.user as string,
password: credentials.password as string, password: credentials.password as string,
host: credentials.host as string, host: (credentials.host as string).trim(),
port: credentials.port as number, port: credentials.port as number,
tls: credentials.secure as boolean, tls: credentials.secure as boolean,
authTimeout: 20000, authTimeout: 20000,
@ -250,7 +250,7 @@ export class EmailReadImapV1 implements INodeType {
const tlsOptions: IDataObject = {}; const tlsOptions: IDataObject = {};
if (credentials.secure) { if (credentials.secure) {
tlsOptions.servername = credentials.host as string; tlsOptions.servername = (credentials.host as string).trim();
} }
if (!isEmpty(tlsOptions)) { if (!isEmpty(tlsOptions)) {
config.imap.tlsOptions = tlsOptions; config.imap.tlsOptions = tlsOptions;
@ -527,7 +527,7 @@ export class EmailReadImapV1 implements INodeType {
imap: { imap: {
user: credentials.user as string, user: credentials.user as string,
password: credentials.password as string, password: credentials.password as string,
host: credentials.host as string, host: (credentials.host as string).trim(),
port: credentials.port as number, port: credentials.port as number,
tls: credentials.secure as boolean, tls: credentials.secure as boolean,
authTimeout: 20000, authTimeout: 20000,
@ -579,7 +579,7 @@ export class EmailReadImapV1 implements INodeType {
} }
if (credentials.secure) { if (credentials.secure) {
tlsOptions.servername = credentials.host as string; tlsOptions.servername = (credentials.host as string).trim();
} }
if (!isEmpty(tlsOptions)) { if (!isEmpty(tlsOptions)) {

View file

@ -34,14 +34,14 @@ export async function parseRawEmail(
): Promise<INodeExecutionData> { ): Promise<INodeExecutionData> {
const responseData = await simpleParser(messageEncoded); const responseData = await simpleParser(messageEncoded);
const headers: IDataObject = {}; const headers: IDataObject = {};
const addidtionalData: IDataObject = {}; const additionalData: IDataObject = {};
for (const header of responseData.headerLines) { for (const header of responseData.headerLines) {
headers[header.key] = header.line; headers[header.key] = header.line;
} }
addidtionalData.headers = headers; additionalData.headers = headers;
addidtionalData.headerLines = undefined; additionalData.headerLines = undefined;
const binaryData: IBinaryKeyData = {}; const binaryData: IBinaryKeyData = {};
if (responseData.attachments) { if (responseData.attachments) {
@ -54,11 +54,11 @@ export async function parseRawEmail(
); );
} }
addidtionalData.attachments = undefined; additionalData.attachments = undefined;
} }
return { return {
json: { ...responseData, ...addidtionalData }, json: { ...responseData, ...additionalData },
binary: Object.keys(binaryData).length ? binaryData : undefined, binary: Object.keys(binaryData).length ? binaryData : undefined,
} as INodeExecutionData; } as INodeExecutionData;
} }
@ -238,7 +238,7 @@ export class EmailReadImapV2 implements INodeType {
imap: { imap: {
user: credentials.user, user: credentials.user,
password: credentials.password, password: credentials.password,
host: credentials.host, host: credentials.host.trim(),
port: credentials.port, port: credentials.port,
tls: credentials.secure, tls: credentials.secure,
authTimeout: 20000, authTimeout: 20000,
@ -251,7 +251,7 @@ export class EmailReadImapV2 implements INodeType {
} }
if (credentials.secure) { if (credentials.secure) {
tlsOptions.servername = credentials.host; tlsOptions.servername = credentials.host.trim();
} }
if (!isEmpty(tlsOptions)) { if (!isEmpty(tlsOptions)) {
config.imap.tlsOptions = tlsOptions; config.imap.tlsOptions = tlsOptions;
@ -554,7 +554,7 @@ export class EmailReadImapV2 implements INodeType {
imap: { imap: {
user: credentials.user, user: credentials.user,
password: credentials.password, password: credentials.password,
host: credentials.host, host: credentials.host.trim(),
port: credentials.port, port: credentials.port,
tls: credentials.secure, tls: credentials.secure,
authTimeout: 20000, authTimeout: 20000,
@ -609,7 +609,7 @@ export class EmailReadImapV2 implements INodeType {
} }
if (credentials.secure) { if (credentials.secure) {
tlsOptions.servername = credentials.host; tlsOptions.servername = credentials.host.trim();
} }
if (!isEmpty(tlsOptions)) { if (!isEmpty(tlsOptions)) {
@ -648,7 +648,7 @@ export class EmailReadImapV2 implements INodeType {
let reconnectionInterval: NodeJS.Timeout | undefined; let reconnectionInterval: NodeJS.Timeout | undefined;
const handleReconect = async () => { const handleReconnect = async () => {
this.logger.verbose('Forcing reconnect to IMAP server'); this.logger.verbose('Forcing reconnect to IMAP server');
try { try {
isCurrentlyReconnecting = true; isCurrentlyReconnecting = true;
@ -665,12 +665,12 @@ export class EmailReadImapV2 implements INodeType {
if (options.forceReconnect !== undefined) { if (options.forceReconnect !== undefined) {
reconnectionInterval = setInterval( reconnectionInterval = setInterval(
handleReconect, handleReconnect,
(options.forceReconnect as number) * 1000 * 60, (options.forceReconnect as number) * 1000 * 60,
); );
} }
// When workflow and so node gets set to inactive close the connectoin // When workflow and so node gets set to inactive close the connection
async function closeFunction() { async function closeFunction() {
closeFunctionWasCalled = true; closeFunctionWasCalled = true;
if (reconnectionInterval) { if (reconnectionInterval) {