# HG changeset patch # User Heiko Schlittermann # Date 1451079066 -3600 # Node ID f44ea3ef0634a307322e1e98acf61bd568065e09 # Parent 2689c9f5f5c5a32bb158abf0e27109c4fe9fb716 ONCE_VAR is VAR now (internal) diff -r 2689c9f5f5c5 -r f44ea3ef0634 once.pl --- a/once.pl Fri Dec 25 22:29:55 2015 +0100 +++ b/once.pl Fri Dec 25 22:31:06 2015 +0100 @@ -65,7 +65,7 @@ die "Environment ONCE_VAR needs to be defined\n" if not defined $ENV{ONCE_VAR}; -my $ONCE_VAR = untaint($ENV{ONCE_VAR}, qr((^/.*))); +my $VAR = untaint($ENV{ONCE_VAR}, qr((^/.*))); exit main() if not caller; @@ -75,12 +75,12 @@ # per view (user) we have an own directory # pre condition checks - -d $ONCE_VAR - or mkdir $ONCE_VAR => 0777 - or die "Can't mkdir $ONCE_VAR: $! (your admin should have created it)\n"; + -d $VAR + or mkdir $VAR => 0777 + or die "Can't mkdir $VAR: $! (your admin should have created it)\n"; - -x -w $ONCE_VAR - or die "Can't write to $ONCE_VAR: $!\n"; + -x -w $VAR + or die "Can't write to $VAR: $!\n"; # Download? # PATH_INFO is something like @@ -93,9 +93,9 @@ { # use Data::Dumper; # die Dumper \%+; - my $view = deslash realpath catfile $ONCE_VAR, $+{view}; - my $store = deslash realpath catfile $ONCE_VAR, $+{store}; - my $file = deslash realpath catfile $ONCE_VAR, $+{path}; + my $view = deslash realpath catfile $VAR, $+{view}; + my $store = deslash realpath catfile $VAR, $+{store}; + my $file = deslash realpath catfile $VAR, $+{path}; my $base = $+{base}; unless (-f $file) { @@ -152,15 +152,15 @@ $d = join '-' => base62(time), base62(rand(10_000)); $v = 'anonymous'; } - $v, deslash catfile($ONCE_VAR, $d); + $v, deslash catfile($VAR, $d); }; # Handle the removal request and we're done if (param('delete') =~ m{(?(?$rxVIEW)/$rxFILE/?)}) { # FIXME: sanitization - my $store = deslash catfile $ONCE_VAR, $+{store}; - my $view = deslash catfile $ONCE_VAR, $+{view}; + my $store = deslash catfile $VAR, $+{store}; + my $view = deslash catfile $VAR, $+{view}; remove_tree $1 if $store =~ m(^(/.*)); rmdir $1 if $view =~ m(^(/.*)); print redirect(-uri => url(-path_info => 1)); @@ -227,7 +227,7 @@ my ($file, $dir) = fileparse($_); $dir = substr $dir, - length $ONCE_VAR; # make it relative to $ONCE_VAR + length $VAR; # make it relative to $VAR # FIXME: use the rx* patterns from above $dir =~ m{/(?[a-z\d]{6})-(?[a-z\d]+)-(?.)}i @@ -269,7 +269,7 @@ sub deletedir { remove_tree map { /^(\/.*)/ } - grep { /^\Q$ONCE_VAR\E/ } @_; + grep { /^\Q$VAR\E/ } @_; } sub humanize {