about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-10-14T09·28+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-10-14T09·28+0200
commita8925a510caab12da8ac12ae897ec5ba79b991c1 (patch)
tree5205aa6a641a02a1b113588c5439d82979c05daa /scripts
parentf1adf4c998c374b3857f2e252cb698463e624059 (diff)
nix-channel --add: Validate URL / channel ID
Fixes #369.
Diffstat (limited to 'scripts')
-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;