mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-23 16:25:22 +03:00
Don't accept fancy lookin letters in Unified configs (#1693)
Don't accept fancy lookin letters in Unified configs
This commit is contained in:
commit
71e538379a
2 changed files with 39 additions and 4 deletions
|
@ -612,6 +612,28 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
self.flashingMessage(i18n.getMessage('firmwareFlasherFirmwareLocalLoaded', self.parsed_hex.bytes_total), self.FLASH_MESSAGE_TYPES.NEUTRAL);
|
||||
}
|
||||
}
|
||||
function cleanUnifiedConfigFile(input) {
|
||||
let output = [];
|
||||
let inComment = false;
|
||||
for (let i=0; i < input.length; i++) {
|
||||
if (input.charAt(i) == "\n" || input.charAt(i) == "\r") {
|
||||
inComment = false;
|
||||
}
|
||||
if (input.charAt(i) == "#") {
|
||||
inComment = true;
|
||||
}
|
||||
if (!inComment && input.charCodeAt(i) > 255) {
|
||||
// Note: we're not showing this error in betaflight-configurator
|
||||
throw new Error('commands are limited to characters 0-255, comments have no limitation');
|
||||
}
|
||||
if (input.charCodeAt(i) > 255) {
|
||||
output.push('_');
|
||||
} else {
|
||||
output.push(input.charAt(i));
|
||||
}
|
||||
}
|
||||
return output.join('');
|
||||
}
|
||||
// UI Hooks
|
||||
$('a.load_file').click(function () {
|
||||
self.enableFlashing(false);
|
||||
|
@ -666,10 +688,15 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
});
|
||||
} else {
|
||||
clearBufferedFirmware();
|
||||
self.unifiedTargetConfig = e.target.result;
|
||||
self.unifiedTargetConfigName = file.name;
|
||||
self.isConfigLocal = true;
|
||||
flashingMessageLocal();
|
||||
try {
|
||||
self.unifiedTargetConfig = cleanUnifiedConfigFile(e.target.result);
|
||||
self.unifiedTargetConfigName = file.name;
|
||||
self.isConfigLocal = true;
|
||||
flashingMessageLocal();
|
||||
} catch(err) {
|
||||
self.flashingMessage('firmwareFlasherConfigCorrupted', self.FLASH_MESSAGE_TYPES.INVALID);
|
||||
GUI.log(i18n.getMessage('firmwareFlasherConfigCorruptedLogMessage'));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue