fix: add some file sanitization
This commit is contained in:
parent
936829338d
commit
e7d9b46097
@ -76,6 +76,8 @@ const intlMessages = defineMessages({
|
|||||||
}, {})
|
}, {})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const MAX_FILE_SIZE = 5000;
|
||||||
|
|
||||||
const VirtualBgSelector = ({
|
const VirtualBgSelector = ({
|
||||||
intl,
|
intl,
|
||||||
handleVirtualBgSelected,
|
handleVirtualBgSelected,
|
||||||
@ -159,7 +161,11 @@ const VirtualBgSelector = ({
|
|||||||
|
|
||||||
const handleCustomBgChange = (event) => {
|
const handleCustomBgChange = (event) => {
|
||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
const { name: filename } = file;
|
const { name: filename, size } = file;
|
||||||
|
const sizeInKB = size / 1024;
|
||||||
|
|
||||||
|
if (sizeInKB > MAX_FILE_SIZE) return;
|
||||||
|
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
const substrings = filename.split('.');
|
const substrings = filename.split('.');
|
||||||
substrings.pop();
|
substrings.pop();
|
||||||
@ -340,6 +346,7 @@ const VirtualBgSelector = ({
|
|||||||
id="customBgSelector"
|
id="customBgSelector"
|
||||||
onChange={handleCustomBgChange}
|
onChange={handleCustomBgChange}
|
||||||
style={{ display: 'none' }}
|
style={{ display: 'none' }}
|
||||||
|
accept="image/png, image/jpeg"
|
||||||
/>
|
/>
|
||||||
<div aria-hidden className="sr-only" id={`vr-cam-btn-custom`}>
|
<div aria-hidden className="sr-only" id={`vr-cam-btn-custom`}>
|
||||||
{intl.formatMessage(intlMessages.customLabel)}
|
{intl.formatMessage(intlMessages.customLabel)}
|
||||||
|
@ -33,6 +33,8 @@ const intlMessages = defineMessages({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const VIDEO_CONTAINER_WIDTH_BOUND = 125;
|
const VIDEO_CONTAINER_WIDTH_BOUND = 125;
|
||||||
|
const MIME_TYPES_ALLOWED = ['image/png', 'image/jpeg'];
|
||||||
|
const MAX_FILE_SIZE = 5000; // KBytes
|
||||||
|
|
||||||
const VideoListItem = (props) => {
|
const VideoListItem = (props) => {
|
||||||
const {
|
const {
|
||||||
@ -279,8 +281,10 @@ const VideoListItem = (props) => {
|
|||||||
|
|
||||||
const { files } = e.dataTransfer;
|
const { files } = e.dataTransfer;
|
||||||
const file = files[0];
|
const file = files[0];
|
||||||
|
const { size, type } = file;
|
||||||
|
const sizeInKB = size / 1024;
|
||||||
|
|
||||||
if (!file.type.startsWith('image')) return;
|
if (sizeInKB > MAX_FILE_SIZE || !MIME_TYPES_ALLOWED.includes(type)) return;
|
||||||
|
|
||||||
if (Session.get('skipBackgroundDropConfirmation')) {
|
if (Session.get('skipBackgroundDropConfirmation')) {
|
||||||
return startAndSaveVirtualBackground(file);
|
return startAndSaveVirtualBackground(file);
|
||||||
|
Loading…
Reference in New Issue
Block a user