libvideosite: limit connector names to letters
[videosite.git] / libvideosite.pm
index da5aefa..3dfe1c3 100644 (file)
@@ -319,6 +319,13 @@ sub _config_has {
     return $b;
 }
 
+sub _config_del {
+    my $path = shift;
+
+    _debug("config: removing %s", join('.', @{$path}));
+    $remote_api->{config_del}->($path);
+}
+
 #
 # The _config_list_* are helper functions taking a path to a comma separated
 # string. The string is interpreted as a list and the action performed
@@ -360,9 +367,9 @@ sub _config_list_del {
     }
 
     _debug("Removing %s from list %s", $item, join('.', @{$path}));
-    @c = map { $item ne $_ } split(/\s*,\s*/, _config_get($path));
+    @c = grep { $item ne $_ } split(/\s*,\s*/, _config_get($path));
 
-    _config_set($path, join('.', @c));
+    _config_set($path, join(',', @c));
 }
 
 #
@@ -714,6 +721,11 @@ sub _cmd_connector {
 
         $name = lc($name);
 
+        unless($name =~ m|^[a-z]+$|) {
+            _io("%s is not a valid connector name (only letters are allowed)", $name);
+            return;
+        }
+
         if (_config_list_has(['defined-connectors'], $name)) {
             _io("Connector already exists");
             return;