fix: media upload security hardening from 6-agent review

- uploadCount: always decrement in finally (prevent permanent uploading state)
- AbortSignal: pass to actual HTTP request (cancel network, not just UI)
- Concurrent uploads: use Set<AbortController> instead of single ref
- DOMPurify hooks: scope inside sanitizeHtml() to avoid global pollution
- Video src: restrict to HTTPS only (was allowing HTTP)
- GIF: remove from accept attributes (backend rejects GIF)
- Ref mutation: move handleMediaUploadRef update to useEffect
This commit is contained in:
Fringg
2026-03-23 12:05:55 +03:00
parent 723591e5c3
commit 74080004e8
3 changed files with 88 additions and 77 deletions

View File

@@ -58,13 +58,13 @@ export const newsApi = {
return response.data;
},
uploadMedia: async (file: File): Promise<NewsMediaUploadResponse> => {
uploadMedia: async (file: File, signal?: AbortSignal): Promise<NewsMediaUploadResponse> => {
const formData = new FormData();
formData.append('file', file);
const response = await apiClient.post<NewsMediaUploadResponse>(
'/cabinet/admin/news/media/upload',
formData,
{ headers: { 'Content-Type': 'multipart/form-data' } },
{ headers: { 'Content-Type': 'multipart/form-data' }, signal },
);
return response.data;
},