Skip to content

Commit 6b8bca0

Browse files
#167 - Sanitize Output filename (#176)
1 parent fed1cff commit 6b8bca0

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ build:
22
cp .env.local_dev .env
33
rm -rf apps/OpenSign/public/mfbuild
44
cd microfrontends/SignDocuments && npm install && npm run build
5-
docker compose up -d
5+
docker compose up --build --force-recreate
66

77
run:
88
cp .env.local_dev .env

microfrontends/SignDocuments/src/Component/LegaDrive/FolderDrive/legaDriveComponent.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function PdfFileComponent({
9999

100100
//function for navigate user to microapp-signature component
101101
const checkPdfStatus = async (data) => {
102-
102+
103103
const hostUrl = getHostUrl();
104104
const expireDate = data.ExpiryDate.iso;
105105
const expireUpdateDate = new Date(expireDate).getTime();
@@ -221,13 +221,19 @@ function PdfFileComponent({
221221
// console.log("download")
222222
const pdfName = data && data.Name;
223223
const pdfUrl = data && data.SignedUrl ? data.SignedUrl : data.URL;
224-
saveAs(pdfUrl, `${pdfName}_signed_by_OpenSign™.pdf`);
224+
saveAs(pdfUrl, `${sanitizeFileName(pdfName)}_signed_by_OpenSign™.pdf`);
225225
} else if (selectType === "Rename") {
226226
// console.log("rename")
227227
setRenameValue(data.Name);
228228
setRename(data.objectId);
229229
}
230230
};
231+
232+
const sanitizeFileName = (pdfName) => {
233+
// Replace spaces with underscore
234+
return pdfName.replace(/ /g, '_');
235+
}
236+
231237
const handleEnterPress = (e, data) => {
232238
if (e.key === "Enter") {
233239
handledRenameDoc(data);

microfrontends/SignDocuments/src/Component/component/emailComponent.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ function EmailComponent({
2828
setIsLoading(true);
2929
let sendMail;
3030
for (let i = 0; i < emailCount.length; i++) {
31-
31+
3232
try {
33-
33+
3434
const imgPng =
3535
"https://qikinnovation.ams3.digitaloceanspaces.com/logo.png";
3636
// "https://qikinnovation.ams3.digitaloceanspaces.com/mailLogo_2023-08-18T12%3A51%3A31.573Z.png";
@@ -41,7 +41,7 @@ function EmailComponent({
4141
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
4242
sessionToken: localStorage.getItem("accesstoken")
4343
};
44-
44+
4545
const themeBGcolor = themeColor();
4646
let params = {
4747
pdfName: pdfName,
@@ -125,12 +125,17 @@ function EmailComponent({
125125

126126
//handle download signed pdf
127127
const handleDownloadPdf = () => {
128-
saveAs(pdfUrl, `${pdfName}_signed_by_OpenSign™.pdf`);
128+
saveAs(pdfUrl, `${sanitizeFileName(pdfName)}_signed_by_OpenSign™.pdf`);
129129
};
130130

131+
const sanitizeFileName = (pdfName) => {
132+
// Replace spaces with underscore
133+
return pdfName.replace(/ /g, '_');
134+
}
135+
131136
const isAndroid = /Android/i.test(navigator.userAgent);
132137

133-
138+
134139
return (
135140
<div>
136141
{/* isEmail */}
@@ -248,13 +253,13 @@ function EmailComponent({
248253
style={{
249254
display: "flex",
250255
flexDirection: "row",
251-
256+
252257
flexWrap: "wrap"
253258
}}
254259
>
255260
{emailCount.map((data, ind) => {
256261
return (
257-
<div className="emailChip"
262+
<div className="emailChip"
258263
style={{display:"flex", flexDirection:"row", alignItems:"center"}}
259264
key={ind}>
260265
<span

microfrontends/SignDocuments/src/Component/component/header.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,15 @@ function Header({
7676
const handleDownloadPdf = () => {
7777
const pdfName = pdfDetails[0] && pdfDetails[0].Name;
7878

79-
saveAs(pdfUrl, `${pdfName}_signed_by_OpenSign™.pdf`);
79+
saveAs(pdfUrl, `${sanitizeFileName(pdfName)}_signed_by_OpenSign™.pdf`);
8080
};
8181

82+
const sanitizeFileName = (pdfName) => {
83+
// Replace spaces with underscore
84+
return pdfName.replace(/ /g, '_');
85+
}
86+
87+
8288
return (
8389
<div
8490
style={{ padding: !isGuestSigner && "5px 0px 5px 0px" }}
@@ -217,7 +223,7 @@ function Header({
217223
</DropdownMenu.Root>
218224
) : (
219225
<div style={{ display: "flex", justifyContent: "space-around" }}>
220-
{/* current signer is checking user send request and check status of pdf sign than if current
226+
{/* current signer is checking user send request and check status of pdf sign than if current
221227
user exist than show finish button else no
222228
*/}
223229
{currentSigner && (

0 commit comments

Comments
 (0)