Skip to content

Commit 403254a

Browse files
Merge pull request #1451 from OpenSignLabs/validation
fix: server get crash in self-hosting
2 parents 3971118 + c893d96 commit 403254a

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

apps/OpenSignServer/cloud/parsefunction/pdf/PDF.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ async function PDF(req) {
384384
isCompleted = true;
385385
}
386386
const randomNumber = Math.floor(Math.random() * 5000);
387+
// below regex is used to replace all word with "_" except A to Z, a to z, numbers
387388
const docName = _resDoc?.Name?.replace(/[^a-zA-Z0-9._-]/g, '_')?.toLowerCase();
388389
const name = `signed_${docName}_${randomNumber}.pdf`;
389390
const filePath = `./exports/${name}`;

apps/OpenSignServer/cloud/parsefunction/sendMailGmailProvider.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ const makeEmail = async (to, from, subject, html, url, pdfName) => {
3737
let Pdf = fs.createWriteStream('test.pdf');
3838
const writeToLocalDisk = () => {
3939
return new Promise((resolve, reject) => {
40-
const isSecure = new URL(url)?.protocol === 'https:';
40+
const isSecure =
41+
new URL(url)?.protocol === 'https:' && new URL(url)?.hostname !== 'localhost';
4142
if (useLocal !== 'true' || isSecure) {
4243
https.get(url, async function (response) {
4344
response.pipe(Pdf);

apps/OpenSignServer/cloud/parsefunction/sendMailv3.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ async function sendMailProvider(req, plan, monthchange) {
3333
let Pdf = fs.createWriteStream('test.pdf');
3434
const writeToLocalDisk = () => {
3535
return new Promise((resolve, reject) => {
36-
const isSecure = new URL(req.params.url)?.protocol === 'https:';
36+
const isSecure =
37+
new URL(req.params.url)?.protocol === 'https:' &&
38+
new URL(req.params.url)?.hostname !== 'localhost';
3739
if (useLocal !== 'true' || isSecure) {
3840
https.get(req.params.url, async function (response) {
3941
response.pipe(Pdf);
@@ -200,7 +202,9 @@ async function sendcustomsmtp(extRes, req) {
200202
let Pdf = fs.createWriteStream('test.pdf');
201203
const writeToLocalDisk = () => {
202204
return new Promise((resolve, reject) => {
203-
const isSecure = new URL(req.params.url)?.protocol === 'https:';
205+
const isSecure =
206+
new URL(req.params.url)?.protocol === 'https:' &&
207+
new URL(req.params.url)?.hostname !== 'localhost';
204208
if (useLocal !== 'true' || isSecure) {
205209
https.get(req.params.url, async function (response) {
206210
response.pipe(Pdf);

0 commit comments

Comments
 (0)