Fix restore GUI for filters with wildcard characters

Change RestoreController.js to handle the case where the selected
restore paths contain literal wildcard characters.  For files, prefix
with `@`.  For directories, convert to regular expression filters so
that we can preserve the literal wildcard characters and also support
the equivalent of a globbing `*` suffix.
This commit is contained in:
Dean Ferreyra
2020-09-03 22:59:24 -07:00
parent b8501dfd77
commit ff91c47f68
@@ -346,10 +346,27 @@ backupApp.controller('RestoreController', function ($rootScope, $scope, $routePa
var paths = [];
for(var n in $scope.Selected) {
var item = $scope.Selected[n];
if (item.substr(item.length - 1) == dirsep)
paths.push(item + '*');
else
paths.push(item);
if (item.indexOf('*') >= 0 || item.indexOf('?')) {
// Handle paths with literal wildcard characters
// specially
if (item.substr(item.length - 1) == dirsep) {
// Switch to a regular expression filter so we can
// preserve the literal wildcard characters and
// also support the equivalent of a globbing '*'
// suffix.
// Escape regular expression metacharacters
var itemRegex = item.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
paths.push('[' + itemRegex + '.*]');
} else {
paths.push('@' + item);
}
} else {
if (item.substr(item.length - 1) == dirsep)
paths.push(item + '*');
else
paths.push(item);
}
}
if (paths.length > 0)