Compare commits

...

3 Commits

Author SHA1 Message Date
crazywoola
dddd72ec83 fix: lint 2024-10-24 17:25:30 +08:00
crazywoola
181572e330 fix: lint 2024-10-24 17:09:54 +08:00
crazywoola
91e5882814
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>
2024-10-24 17:05:09 +08:00
2 changed files with 4 additions and 2 deletions

View File

@ -10,6 +10,8 @@ import { ImagePlus } from '../icons/src/vender/line/images'
import { useDraggableUploader } from './hooks'
import { ALLOW_FILE_EXTENSIONS } from '@/types/app'
const MAX_FILE_SIZE = 5 * 1024 * 1024
type UploaderProps = {
className?: string
onImageCropped?: (tempUrl: string, croppedAreaPixels: Area, fileName: string) => void
@ -38,7 +40,7 @@ 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) })
}

View File

@ -1,4 +1,4 @@
export const createImage = (url: string) =>
const createImage = (url: string) =>
new Promise<HTMLImageElement>((resolve, reject) => {
const image = new Image()
image.addEventListener('load', () => resolve(image))