diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-10-14 11:28:13 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-10-14 11:28:13 +0200 |
commit | a8925a510caab12da8ac12ae897ec5ba79b991c1 (patch) | |
tree | 5205aa6a641a02a1b113588c5439d82979c05daa | |
parent | f1adf4c998c374b3857f2e252cb698463e624059 (diff) |
nix-channel --add: Validate URL / channel ID
Fixes #369.
-rwxr-xr-x | scripts/nix-channel.in | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in index e45b91338..8e07821c4 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; |