| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Spike::Site::Request; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 3 | use strict; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 21 |  | 
| 4 | 1 |  |  | 1 |  | 2 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 20 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 1 |  |  | 1 |  | 3 | use base qw(Plack::Request Spike::Object); | 
|  | 1 |  |  |  |  | 0 |  | 
|  | 1 |  |  |  |  | 425 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 1 |  |  | 1 |  | 47993 | use Spike::Site::Response; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 21 |  | 
| 9 | 1 |  |  | 1 |  | 4 | use List::Util qw(min); | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 382 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 | 0 |  |  | 0 | 1 |  | sub new_response { shift; Spike::Site::Response->new(@_) } | 
|  | 0 |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | sub _bind_named_url_parameters { | 
| 14 | 0 |  |  | 0 |  |  | my $self = shift; | 
| 15 |  |  |  |  |  |  |  | 
| 16 | 0 |  |  |  |  |  | my $bind = $self->env->{'spike.request.named_url_parameters'} = []; | 
| 17 |  |  |  |  |  |  |  | 
| 18 | 0 |  |  |  |  |  | while (@_) { | 
| 19 | 0 |  |  |  |  |  | my ($name, $value) = splice @_, 0, 2; | 
| 20 |  |  |  |  |  |  |  | 
| 21 | 0 | 0 |  |  |  |  | last if !defined $name; | 
| 22 | 0 | 0 |  |  |  |  | next if $name !~ s!^#!!; | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 0 |  |  |  |  |  | push @$bind, $name, $value; | 
| 25 |  |  |  |  |  |  | } | 
| 26 |  |  |  |  |  |  |  | 
| 27 | 0 |  |  |  |  |  | delete $self->env->{'spike.request.named_url'}; | 
| 28 | 0 |  |  |  |  |  | delete $self->env->{'spike.request.merged'}; | 
| 29 |  |  |  |  |  |  | } | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | sub _named_url_parameters { | 
| 32 | 0 |  |  | 0 |  |  | my $self = shift; | 
| 33 | 0 |  | 0 |  |  |  | $self->env->{'spike.request.named_url_parameters'} ||= []; | 
| 34 |  |  |  |  |  |  | } | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | sub named_url_parameters { | 
| 37 | 0 |  |  | 0 | 0 |  | my $self = shift; | 
| 38 | 0 |  | 0 |  |  |  | $self->env->{'spike.request.named_url'} ||= Hash::MultiValue->new(@{$self->_named_url_parameters}); | 
|  | 0 |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | sub parameters { | 
| 42 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | $self->env->{'spike.request.merged'} ||= Hash::MultiValue->new( | 
| 45 |  |  |  |  |  |  | $self->SUPER::parameters->flatten, | 
| 46 | 0 |  | 0 |  |  |  | @{$self->_named_url_parameters}, | 
|  | 0 |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | ); | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | sub safe_path { | 
| 51 | 0 |  |  | 0 | 0 |  | my $self = shift; | 
| 52 |  |  |  |  |  |  |  | 
| 53 | 0 | 0 |  |  |  |  | if (!defined $self->env->{'spike.request.safe_path'}) { | 
| 54 | 0 |  |  |  |  |  | my @parts; | 
| 55 |  |  |  |  |  |  |  | 
| 56 | 0 | 0 |  |  |  |  | for my $part (grep { defined && length } split m!/+!, $self->path_info) { | 
|  | 0 |  |  |  |  |  |  | 
| 57 | 0 |  |  |  |  |  | $part =~ s!\0!!g; | 
| 58 |  |  |  |  |  |  |  | 
| 59 | 0 | 0 |  |  |  |  | if ($part eq '.') { | 
|  |  | 0 |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | # do nothing | 
| 61 |  |  |  |  |  |  | } | 
| 62 |  |  |  |  |  |  | elsif ($part eq '..') { | 
| 63 | 0 |  |  |  |  |  | pop @parts; | 
| 64 |  |  |  |  |  |  | } | 
| 65 |  |  |  |  |  |  | else { | 
| 66 | 0 |  |  |  |  |  | push @parts, $part; | 
| 67 |  |  |  |  |  |  | } | 
| 68 |  |  |  |  |  |  | } | 
| 69 |  |  |  |  |  |  |  | 
| 70 | 0 |  |  |  |  |  | $self->env->{'spike.request.safe_path'} = join '/', @parts; | 
| 71 |  |  |  |  |  |  | } | 
| 72 |  |  |  |  |  |  | } | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | 1; |