Repository navigation
v1.20.0
Minor Changes
-
07af05f:
react-smart-copy/files: take pasted and dropped files and folders safely.acceptFiles(source, options)takes a paste or drop event (DOM or React), aDataTransfer, aFileListor a list of files. It walks dropped folders withinmaxFiles,maxFileBytes,maxTotalBytesandmaxDepth, and accepts or rejects each file with areasonand a message that names the file by its safe name. Withdigest: true, each file gets a SHA-256 and repeated files are rejected asduplicate.- Types come from content, never from names or claimed types: more than 50 formats are recognised by their signatures, including Office and OpenDocument files told apart inside their ZIP.
acceptworks like<input accept>, judged by content. Each accepted file'suploadis the same bytes, with the safe name and the detected type. - Risky files are rejected by default: programs and scripts, HTML and SVG (active content), Office files with macros, content that contradicts the extension, double extensions (
invoice.pdf.exe), and hidden characters in names (photo\u202Egpj.exe).blockchooses which risks reject. inspectFile,detectFileType,safeFileNameandmatchesAcceptare exported as building blocks. Everything works on servers too (Node 18+).