📌 Description
src/features/dashboard/pages/ProfilePage.tsx (has a test file already) likely includes an avatar upload/change flow. Without explicit client-side validation, a user could select an oversized file (slow/failed upload), a non-image file (broken rendering), or an SVG containing embedded script (a known XSS vector for user-uploaded SVGs if rendered inline).
🧩 Requirements and context
- Add file-type validation limited to safe raster formats (reject SVG uploads or strip/sanitize them server-side — flag as a backend follow-up if SVG must be supported).
- Add a file-size limit with a clear error message before attempting upload.
- Add a test for each rejected case and for a valid small image succeeding.
Non-functional requirements
- Must be secure, tested, and documented.
- Should be efficient and easy to review.
🛠️ Suggested execution
1. Fork the repo and create a branch
git checkout -b fix/profile-avatar-upload-validation
2. Implement changes
- Modify:
src/features/dashboard/pages/ProfilePage.tsx — add pre-upload file validation.
- Modify:
src/features/dashboard/pages/ProfilePage.test.tsx — add the validation test cases.
3. Test and commit
npm test -- run ProfilePage
- Cover edge cases: oversized file, non-image file with an image-like extension, SVG file upload, zero-byte file.
- Include test output and details in the PR description.
Example commit message
fix: add file-type and size validation to avatar upload
✅ Acceptance criteria
🔒 Security notes
SVG uploads rendered inline/unsanitized are a known stored-XSS vector (SVGs can embed <script>); if SVG support is required, flag server-side sanitization as a mandatory companion fix, don't rely on client-side rejection alone as the only defense.
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
src/features/dashboard/pages/ProfilePage.tsx(has a test file already) likely includes an avatar upload/change flow. Without explicit client-side validation, a user could select an oversized file (slow/failed upload), a non-image file (broken rendering), or an SVG containing embedded script (a known XSS vector for user-uploaded SVGs if rendered inline).🧩 Requirements and context
Non-functional requirements
🛠️ Suggested execution
1. Fork the repo and create a branch
2. Implement changes
src/features/dashboard/pages/ProfilePage.tsx— add pre-upload file validation.src/features/dashboard/pages/ProfilePage.test.tsx— add the validation test cases.3. Test and commit
npm test -- run ProfilePageExample commit message
✅ Acceptance criteria
🔒 Security notes
SVG uploads rendered inline/unsanitized are a known stored-XSS vector (SVGs can embed
<script>); if SVG support is required, flag server-side sanitization as a mandatory companion fix, don't rely on client-side rejection alone as the only defense.📋 Guidelines