Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix: email validation case insensitive

Marc Seitz66fa065dad95
diff --git a/components/datarooms/add-viewer-modal.tsx b/components/datarooms/add-viewer-modal.tsx
index cd41f5c5..3865d008 100644
--- a/components/datarooms/add-viewer-modal.tsx
+++ b/components/datarooms/add-viewer-modal.tsx
@@ -92,7 +92,7 @@ export function AddViewerModal({
// Split the current input value by commas in case of pasting multiple emails
const potentialEmails = inputValue
.split(",")
- .map((email) => email.trim())
+ .map((email) => email.trim().toLowerCase())
.filter((email) => email);
const newEmails = potentialEmails.filter((email) => {
diff --git a/components/view/access-form/email-section.tsx b/components/view/access-form/email-section.tsx
index 4dfdee46..fe1b3354 100644
--- a/components/view/access-form/email-section.tsx
+++ b/components/view/access-form/email-section.tsx
@@ -15,12 +15,15 @@ export default function EmailSection({
// Load email from localStorage when the component mounts
const storedEmail = window.localStorage.getItem("papermark.email");
if (storedEmail) {
- setData((prevData) => ({ ...prevData, email: storedEmail }));
+ setData((prevData) => ({
+ ...prevData,
+ email: storedEmail.toLowerCase(),
+ }));
}
}, [setData]);
const handleEmailChange = (e: React.ChangeEvent<HTMLInputElement>) => {
- const newEmail = e.target.value;
+ const newEmail = e.target.value.toLowerCase();
// Store the new email in localStorage
window.localStorage.setItem("papermark.email", newEmail);
// Update the state
diff --git a/lib/utils.ts b/lib/utils.ts
index 0823805e..67083126 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -487,7 +487,7 @@ export const sanitizeAllowDenyList = (list: string): string[] => {
return list
.split("\n")
- .map((item) => item.trim().replace(/,$/, "")) // Trim whitespace and remove trailing commas
+ .map((item) => item.trim().replace(/,$/, "").toLowerCase()) // Trim whitespace and remove trailing commas and lowercase
.filter((item) => item !== "") // Remove empty items
.filter((item) => emailRegex.test(item) || domainRegex.test(item)); // Remove items that don't match email or domain regex
};