Allow http/https only for Flash from URL

Change-type: patch
Changelog-entry: Allow http/https only for Flash from URL
Signed-off-by: Lorenzo Alberto Maria Ambrosi <lorenzothunder.ambrosi@gmail.com>
This commit is contained in:
Lorenzo Alberto Maria Ambrosi 2020-04-24 15:04:24 +02:00
parent ac2e973cb0
commit 39ed67d667
2 changed files with 18 additions and 1 deletions

View File

@ -47,7 +47,7 @@ import { SVGIcon } from '../svg-icon/svg-icon';
const recentUrlImagesKey = 'recentUrlImages';
function normalizeRecentUrlImages(urls: any[]): string[] {
function normalizeRecentUrlImages(urls: any): string[] {
if (!Array.isArray(urls)) {
urls = [];
}
@ -362,6 +362,19 @@ export class SourceSelector extends React.Component<
path: imagePath,
});
} else {
if (
!_.startsWith(imagePath, 'https://') &&
!_.startsWith(imagePath, 'http://')
) {
const invalidImageError = errors.createUserError({
title: 'Unsupported protocol',
description: messages.error.unsupportedProtocol(),
});
osDialog.showError(invalidImageError);
analytics.logEvent('Unsupported protocol', { path: imagePath });
return;
}
source = new sourceDestination.Http(imagePath);
}

View File

@ -191,4 +191,8 @@ export const error = {
'Please try again, and contact the Etcher team if the problem persists.',
].join(' ');
},
unsupportedProtocol: () => {
return 'Only http:// and https:// URLs are supported.';
},
};