Added input validation for B2 paths to avoid users ending up with weird error messages, once the full path for each file is constructed.

This commit is contained in:
Kenneth Skovhede
2018-06-07 13:14:11 +02:00
parent e6535e2cfa
commit af3e9cdfdc
@@ -875,6 +875,30 @@ backupApp.service('EditUriBuiltins', function(AppService, AppUtils, SystemInfo,
EditUriBackendConfig.require_field(scope, 'Username', gettextCatalog.getString('B2 Cloud Storage Account ID')) &&
EditUriBackendConfig.require_field(scope, 'Password', gettextCatalog.getString('B2 Cloud Storage Application Key'));
if (res) {
var re = new RegExp('[^A-Za-z0-9-]');
var bucketname = scope['Server'] || '';
var ix = bucketname.search(/[^A-Za-z0-9-]/g);
if (ix >= 0) {
EditUriBackendConfig.show_error_dialog(gettextCatalog.getString('The \'{{fieldname}}\' field contains an invalid character: {{character}} (value: {{value}}, index: {{pos}})', { value: bucketname[ix].charCodeAt(), pos: ix, character: bucketname[ix], fieldname: gettextCatalog.getString('Bucket Name') }));
res = false;
}
}
if (res) {
var pathname = scope['Path'] || '';
for (var i = pathname.length - 1; i >= 0; i--) {
var char = pathname.charCodeAt(i);
if (char == '\\'.charCodeAt(0) || char == 127 || char < 32) {
EditUriBackendConfig.show_error_dialog(gettextCatalog.getString('The \'{{fieldname}}\' field contains an invalid character: {{character}} (value: {{value}}, index: {{pos}})', { value: char, pos: i, character: pathname[i], fieldname: gettextCatalog.getString('Path') }));
res = false;
break;
}
}
}
if (res)
continuation();
};