-
Notifications
You must be signed in to change notification settings - Fork 11
Fix/security input validation #303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7e27124
d326d5c
b11826c
6540a68
14e3d6a
2ca5be5
7cd02da
4186251
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,28 @@ export default async function handler(req, res) { | |
| }); | ||
| } | ||
|
|
||
| // Validate email format | ||
| const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about setting
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or something like zod? it works well with react hook forms |
||
| if (!emailRegex.test(email)) { | ||
| return res.status(422).json({ | ||
| message: 'Invalid email format', | ||
| }); | ||
| } | ||
|
|
||
| // Validate name length (max 100 characters) | ||
| if (name.length > 100) { | ||
| return res.status(422).json({ | ||
| message: 'Name must be 100 characters or less', | ||
| }); | ||
| } | ||
|
|
||
| // Validate message length if provided (max 5000 characters) | ||
| if (message && message.length > 5000) { | ||
| return res.status(422).json({ | ||
| message: 'Message must be 5000 characters or less', | ||
| }); | ||
| } | ||
|
|
||
| try { | ||
| // Ping the google recaptcha verify API to verify the captcha code you received | ||
| const response = await fetch( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.