From a8925a510caab12da8ac12ae897ec5ba79b991c1 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 14 Oct 2014 11:28:13 +0200 Subject: [PATCH] nix-channel --add: Validate URL / channel ID Fixes #369. --- scripts/nix-channel.in | 2 ++ 1 file changed, 2 insertions(+) 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;