2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-06-12 11:38:47 +00:00

Remove image download support (#11962)

* Remove image download support

- Helper function remains (it is used in the supplier plugin mixin)
- No longer available to user
- Close massive security hole entirely
- Will be defunct soon anyway (moving to generic attachments)

* Update CHANGELOG.md

* Bump API version

* Fix for unit tests
This commit is contained in:
Oliver
2026-05-19 07:02:05 +10:00
committed by GitHub
parent acc2786e44
commit 99358eb4e7
12 changed files with 24 additions and 194 deletions
@@ -29,8 +29,6 @@ import { showNotification } from '@mantine/notifications';
import { api } from '../../App';
import { InvenTreeIcon } from '../../functions/icons';
import { showApiErrorMessage } from '../../functions/notifications';
import { useEditApiFormModal } from '../../hooks/UseForm';
import { useGlobalSettingsState } from '../../states/SettingsStates';
import { useUserState } from '../../states/UserState';
import { PartThumbTable } from '../../tables/part/PartThumbTable';
import { vars } from '../../theme';
@@ -320,8 +318,7 @@ function ImageActionButtons({
apiPath,
hasImage,
pk,
setImage,
downloadImage
setImage
}: Readonly<{
actions?: DetailImageButtonProps;
visible: boolean;
@@ -329,10 +326,7 @@ function ImageActionButtons({
hasImage: boolean;
pk: string;
setImage: (image: string) => void;
downloadImage: () => void;
}>) {
const globalSettings = useGlobalSettingsState();
return (
<>
{visible && (
@@ -363,25 +357,6 @@ function ImageActionButtons({
}}
/>
)}
{actions.downloadImage &&
globalSettings.isSet('INVENTREE_DOWNLOAD_FROM_URL') && (
<ActionButton
icon={
<InvenTreeIcon
icon='download'
iconProps={{ color: 'white' }}
/>
}
tooltip={t`Download remote image`}
variant='outline'
size='lg'
tooltipAlignment='top'
onClick={(event: any) => {
cancelEvent(event);
downloadImage();
}}
/>
)}
{actions.uploadFile && (
<ActionButton
icon={
@@ -439,21 +414,6 @@ export function DetailsImage(props: Readonly<DetailImageProps>) {
const permissions = useUserState();
const downloadImage = useEditApiFormModal({
url: props.apiPath,
title: t`Download Image`,
fields: {
remote_image: {}
},
timeout: 10000,
successMessage: t`Image downloaded successfully`,
onFormSuccess: (response: any) => {
if (response.image) {
setAndRefresh(response.image);
}
}
});
const hasOverlay: boolean = useMemo(() => {
return (
props.imageActions?.selectExisting ||
@@ -473,7 +433,6 @@ export function DetailsImage(props: Readonly<DetailImageProps>) {
return (
<>
{downloadImage.modal}
<Grid.Col span={{ base: 12, sm: 4 }}>
<AspectRatio
ref={ref}
@@ -502,7 +461,6 @@ export function DetailsImage(props: Readonly<DetailImageProps>) {
hasImage={!!props.src}
pk={props.pk}
setImage={setAndRefresh}
downloadImage={downloadImage.open}
/>
</Overlay>
)}
@@ -59,15 +59,7 @@ export default function SystemSettings() {
'INVENTREE_RESTRICT_ABOUT',
'DISPLAY_FULL_NAMES',
'DISPLAY_PROFILE_INFO',
'WEEK_STARTS_ON'
]}
/>
<GlobalSettingList
heading={t`Image Download Settings`}
keys={[
'INVENTREE_DOWNLOAD_FROM_URL',
'INVENTREE_DOWNLOAD_IMAGE_MAX_SIZE',
'INVENTREE_DOWNLOAD_FROM_URL_USER_AGENT',
'WEEK_STARTS_ON',
'INVENTREE_STRICT_URLS'
]}
/>