mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-24 07:17:18 +00:00
Prevent selection of invalid images (#462)
The user might attempt to select an invalid image by dropping on the first step, which would cause Etcher to blindly select it, possibly causing errors later on the process. This PR makes use of the list of supported extensions provided by `SupportedFormatsModel` and prevents the selection if necessary, logging an event that might help us determine which unsupported image types users try to burn most often. Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This commit is contained in:
parent
0557c45102
commit
fc6ccf70dd
@ -21,6 +21,7 @@
|
||||
'use strict';
|
||||
|
||||
var angular = require('angular');
|
||||
const path = require('path');
|
||||
const _ = require('lodash');
|
||||
|
||||
const app = angular.module('Etcher', [
|
||||
@ -188,6 +189,13 @@ app.controller('AppController', function(
|
||||
document.querySelector('body').style.display = 'initial';
|
||||
|
||||
this.selectImage = function(image) {
|
||||
const extension = path.extname(image.path).slice(1);
|
||||
|
||||
if (!_.includes(SupportedFormatsModel.getAllExtensions(), extension)) {
|
||||
AnalyticsService.logEvent('Invalid image', image);
|
||||
return;
|
||||
}
|
||||
|
||||
self.selection.setImage(image);
|
||||
AnalyticsService.logEvent('Select image', image);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user