about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/nix-channel.in2
1 files changed, 2 insertions, 0 deletions
diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in
index e45b913382a7..8e07821c43c7 100755
--- a/scripts/nix-channel.in
+++ b/scripts/nix-channel.in
@@ -61,6 +61,8 @@ sub writeChannels {
 # Adds a channel.
 sub addChannel {
     my ($url, $name) = @_;
+    die "invalid channel URL ‘$url’" unless $url =~ /^(file|http|https):\/\//;
+    die "invalid channel identifier ‘$name’" unless $name =~ /^[a-zA-Z0-9_][a-zA-Z0-9_\-\.]*$/;
     readChannels;
     $channels{$name} = $url;
     writeChannels;