]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: FW log ratelimit: avoid access on possible undefined rate
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 16 May 2019 08:31:00 +0000 (10:31 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 16 May 2019 08:31:02 +0000 (10:31 +0200)
This is an optional parameter and needs to be guarded, a simple
"truthy" check is enough, as eithers it's missing or a more complex
string (i.e., it cannot be '0' or the like)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
www/manager6/window/FirewallLograteEdit.js

index 1ac8ea551ea8219a5a0df092f370a77f1ebc0a1d..3d6d0cac3fd2dbecaf2cb74ebd2603d8ef53b113 100644 (file)
@@ -71,11 +71,13 @@ Ext.define('PVE.FirewallLograteInputPanel', {
 
        var properties = {};
        if (values.log_ratelimit !== undefined) {
-           properties = PVE.Parser.parsePropertyString(values.log_ratelimit);
-           var matches = properties.rate.match(/^(\d+)\/(second|minute|hour|day)$/);
-           if (matches) {
-               properties.rate = matches[1];
-               properties.unit = matches[2];
+           properties = PVE.Parser.parsePropertyString(values.log_ratelimit, 'enable');
+           if (properties.rate) {
+               var matches = properties.rate.match(/^(\d+)\/(second|minute|hour|day)$/);
+               if (matches) {
+                   properties.rate = matches[1];
+                   properties.unit = matches[2];
+               }
            }
        }
        me.callParent([properties]);