Fix code scanning alert no. 89: DOM text reinterpreted as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
crazywoola 2024-10-24 17:05:09 +08:00 committed by GitHub
parent fc63841169
commit 91e5882814
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,7 @@
'use client'
const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
import type { ChangeEvent, FC } from 'react'
import { createRef, useEffect, useState } from 'react'
import type { Area } from 'react-easy-crop'
@ -38,9 +40,10 @@ const Uploader: FC<UploaderProps> = ({
const handleLocalFileInput = (e: ChangeEvent<HTMLInputElement>) => {
const file = e.target.files?.[0]
if (file)
if (file && ALLOW_FILE_EXTENSIONS.includes(file.type.split('/').pop()?.toLowerCase() || '') && file.size <= MAX_FILE_SIZE) {
setInputImage({ file, url: URL.createObjectURL(file) })
}
}
const {
isDragActive,