Skip to content
Snippets Groups Projects
Commit 56373b59 authored by fooker's avatar fooker Committed by codedust
Browse files

Escape regex in device name the right way

parent c5ae1abd
No related branches found
No related tags found
No related merge requests found
...@@ -1048,20 +1048,13 @@ var firmwarewizard = function() { ...@@ -1048,20 +1048,13 @@ var firmwarewizard = function() {
}); });
// prepare the matches for use in regex (join by pipe and escape dots) // prepare the matches for use in regex (join by pipe and escape dots)
var matchString = matches.join('|').replace(/\./g, '\.'); var matchString = matches.map(x => x.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|');
// match image files. The match either ends with // match image files. The match either ends with
// - a dash or dot (if a file extension will follow) // - a dash or dot (if a file extension will follow)
// - the end of the expression (if the file extension is part of the regex) // - the end of the expression (if the file extension is part of the regex)
var reMatch = new RegExp('('+matchString+')([.-]|$)'); var reMatch = new RegExp('('+matchString+')([.-]|$)');
// check if image regexes contain regular expressions themself
var reCheckRegex = new RegExp(/[^\\]+[+?*]/);
if (reCheckRegex.exec(matches.join('|')) !== null) {
console.log("Warning! Some regular expressions for firmware images, contain unescaped characters.");
}
var sitesLoadedSuccessfully = 0; var sitesLoadedSuccessfully = 0;
for (var indexPath in config.directories) { for (var indexPath in config.directories) {
// retrieve the contents of the directory // retrieve the contents of the directory
......
...@@ -131,7 +131,7 @@ var devices_recommended = { ...@@ -131,7 +131,7 @@ var devices_recommended = {
"UniFi AP AC Pro": "ubiquiti-unifi-ac-pro", "UniFi AP AC Pro": "ubiquiti-unifi-ac-pro",
"UniFi AP AC Lite": "ubiquiti-unifi-ac-lite", "UniFi AP AC Lite": "ubiquiti-unifi-ac-lite",
"UniFi AP Outdoor": {"ubiquiti-unifi-outdoor": "", "ubiquiti-unifiap-outdoor": ""}, "UniFi AP Outdoor": {"ubiquiti-unifi-outdoor": "", "ubiquiti-unifiap-outdoor": ""},
"UniFi AP Outdoor+": {"ubiquiti-unifi-outdoor-plus": "", "ubiquiti-unifiap-outdoor\\\+": "", "ubiquiti-unifiap-outdoor%2B": "", "ubiquiti-unifiap-outdoor%2b": ""} "UniFi AP Outdoor+": {"ubiquiti-unifi-outdoor-plus": "", "ubiquiti-unifiap-outdoor+": "", "ubiquiti-unifiap-outdoor%2B": "", "ubiquiti-unifiap-outdoor%2b": ""}
}, },
"VoCore": { "VoCore": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment