🌊 Волна 15: frontend #5 — security + юзабилити (16 багов)

Security (XSS):
- feed_modal_javascript_url_xss: safeUrl валидация (FeedModal.tsx)
- feed_modal_telegram_url_xss: safeUrl валидация (FeedModal.tsx)

Данные:
- feed_composer_duplicate_post_on_upload_fail: isPublished флаг (FeedPostComposer.tsx)
- STRICTMODE_DOUBLE_REGISTER_RETRY: двойная защита + cleanup (App.tsx)
- RETRY_TIMEOUT_NOT_CLEANED: clearTimeout в cleanup (App.tsx)

Производительность:
- CONTENT_TYPE_ON_GET_TRIGGERS_PREFLIGHT: Content-Type только при body (api.ts)
- DUPLICATED_FETCH_LOGIC: fetchWithTimeout helper (api.ts)
- UNENCODED_PATH_PARAMS: encodeURIComponent для path (api.ts)

Юзабилити:
- content_editor_no_escape: Escape (ContentEditorMenu.tsx)
- lessons_editor_no_backdrop_close: Escape + backdrop (LessonsEditor.tsx)
- support_delete_ticket_no_confirm: модалка подтверждения (SupportChatModal.tsx)

Качество:
- GET_INIT_DATA_CONSOLE_SPAM: логируем один раз (telegram.ts)
- words_editor_dead_button: удалена мёртвая кнопка (WordsEditor.tsx)
- highlights_carousel_setstate_on_unmount: убран setState в cleanup (HighlightsCarousel.tsx)
- image_lightbox_timers_accumulate: очистка таймеров (ImageLightbox.tsx)
- typing_modal_timeout_not_cleared: clearTimeout (TypingModal.tsx)

Пропущено осознанно:
- INIT_DATA_IN_URL_DELETE_FEED (fallback для deleteFeedPost, Cloudflare preflight)

Аудит v3: Issue #4, frontend 17/18 задач
This commit is contained in:
2026-09-24 19:21:24 +03:00
parent 66c90c16e9
commit 87f482861b
12 changed files with 287 additions and 89 deletions
+14 -3
View File
@@ -28,6 +28,9 @@ const TypingModal: React.FC<TypingModalProps> = ({ isOpen, onClose }) => {
const [isPlaying, setIsPlaying] = useState(false);
const audioRef = useRef<HTMLAudioElement | null>(null);
const isMountedRef = useRef(true);
// 🔧 ФИКС (24.09.2026): typing_modal_timeout_not_cleared —
// храним таймер для очистки.
const fetchTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const brandColor = '#2ECC71';
const textColor = '#1A1A2E';
@@ -43,7 +46,7 @@ const TypingModal: React.FC<TypingModalProps> = ({ isOpen, onClose }) => {
...extra,
});
// 🔧 ФИКС (22.09.2026): утечка ObjectURL в playAnswer.
// 🔧 ФИКС (22.09.2026): утечка ObjectURL в playAnswer.
const audioUrlRef = useRef<string | null>(null);
const stopAudio = () => {
@@ -103,6 +106,11 @@ const TypingModal: React.FC<TypingModalProps> = ({ isOpen, onClose }) => {
return () => {
isMountedRef.current = false;
stopAudio();
// 🔧 ФИКС (24.09.2026): typing_modal_timeout_not_cleared
if (fetchTimeoutRef.current) {
clearTimeout(fetchTimeoutRef.current);
fetchTimeoutRef.current = null;
}
};
}, [isOpen, fetchSentence]);
@@ -116,7 +124,10 @@ const TypingModal: React.FC<TypingModalProps> = ({ isOpen, onClose }) => {
if (data.correct) {
setTotalCompleted(prev => prev + 1);
setTimeout(() => {
// 🔧 ФИКС (24.09.2026): typing_modal_timeout_not_cleared —
// сохраняем id таймера для очистки.
if (fetchTimeoutRef.current) clearTimeout(fetchTimeoutRef.current);
fetchTimeoutRef.current = setTimeout(() => {
if (isMountedRef.current) {
fetchSentence();
}
@@ -153,7 +164,7 @@ const TypingModal: React.FC<TypingModalProps> = ({ isOpen, onClose }) => {
setShowAnswer(true);
};
const playAnswer = async () => {
const playAnswer = async () => {
if (!correctAnswer) return;
stopAudio();
setIsPlaying(true);