diff --git a/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.js b/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.js index c367923d9..ce14dbf72 100644 --- a/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.js +++ b/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.js @@ -384,6 +384,7 @@ async function PDF(req) { isCompleted = true; } const randomNumber = Math.floor(Math.random() * 5000); + // below regex is used to replace all word with "_" except A to Z, a to z, numbers const docName = _resDoc?.Name?.replace(/[^a-zA-Z0-9._-]/g, '_')?.toLowerCase(); const name = `signed_${docName}_${randomNumber}.pdf`; const filePath = `./exports/${name}`; diff --git a/apps/OpenSignServer/cloud/parsefunction/sendMailGmailProvider.js b/apps/OpenSignServer/cloud/parsefunction/sendMailGmailProvider.js index fa77bcffc..b6321362d 100644 --- a/apps/OpenSignServer/cloud/parsefunction/sendMailGmailProvider.js +++ b/apps/OpenSignServer/cloud/parsefunction/sendMailGmailProvider.js @@ -37,7 +37,8 @@ const makeEmail = async (to, from, subject, html, url, pdfName) => { let Pdf = fs.createWriteStream('test.pdf'); const writeToLocalDisk = () => { return new Promise((resolve, reject) => { - const isSecure = new URL(url)?.protocol === 'https:'; + const isSecure = + new URL(url)?.protocol === 'https:' && new URL(url)?.hostname !== 'localhost'; if (useLocal !== 'true' || isSecure) { https.get(url, async function (response) { response.pipe(Pdf); diff --git a/apps/OpenSignServer/cloud/parsefunction/sendMailv3.js b/apps/OpenSignServer/cloud/parsefunction/sendMailv3.js index 874919511..2cb484f6a 100644 --- a/apps/OpenSignServer/cloud/parsefunction/sendMailv3.js +++ b/apps/OpenSignServer/cloud/parsefunction/sendMailv3.js @@ -33,7 +33,9 @@ async function sendMailProvider(req, plan, monthchange) { let Pdf = fs.createWriteStream('test.pdf'); const writeToLocalDisk = () => { return new Promise((resolve, reject) => { - const isSecure = new URL(req.params.url)?.protocol === 'https:'; + const isSecure = + new URL(req.params.url)?.protocol === 'https:' && + new URL(req.params.url)?.hostname !== 'localhost'; if (useLocal !== 'true' || isSecure) { https.get(req.params.url, async function (response) { response.pipe(Pdf); @@ -200,7 +202,9 @@ async function sendcustomsmtp(extRes, req) { let Pdf = fs.createWriteStream('test.pdf'); const writeToLocalDisk = () => { return new Promise((resolve, reject) => { - const isSecure = new URL(req.params.url)?.protocol === 'https:'; + const isSecure = + new URL(req.params.url)?.protocol === 'https:' && + new URL(req.params.url)?.hostname !== 'localhost'; if (useLocal !== 'true' || isSecure) { https.get(req.params.url, async function (response) { response.pipe(Pdf);