mirror of
https://github.com/System-End/site.git
synced 2026-04-19 19:45:07 +00:00
fix: css injection, estimated hour validation
Fix potential point of CSS injection validate estimated hours to be a positive integer
This commit is contained in:
parent
f813b8c1b0
commit
a8bc0e5508
1 changed files with 19 additions and 0 deletions
|
|
@ -12,6 +12,25 @@ export default async function handler(req, res) {
|
|||
return res.status(400).json({ error: 'No body provided' })
|
||||
}
|
||||
|
||||
// html color input value always gives a 6-char hex color
|
||||
const colorRegex = /^#[0-9A-F]{6}$/i;
|
||||
if(body.color !== "" && !(colorRegex.test(body.color))) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: 'Invalid Color' });
|
||||
}
|
||||
if(body.textColor !== "" && !(colorRegex.test(body.textColor))) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: 'Invalid Text Color' });
|
||||
}
|
||||
|
||||
if(body.hours <= 0) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: 'Hours should be a positive integer' });
|
||||
}
|
||||
|
||||
const updatedFields = {}
|
||||
updatedFields['Name'] = body.title
|
||||
updatedFields['Estimated Hours'] = body.hours
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue