X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FWeb%2FSimple%2FDispatchParser.pm;h=6b43316aaebcbb9477dbb0ff251036c26ee306c2;hb=b0420ad6326a86fe33cdbecfb58bba08bec52b74;hp=2c28924f0b46cdc63fa7cf8fe61b3fcc8211cf6f;hpb=da9b9236e0cb51e61c0c0540a493d282318846c4;p=catagits%2FWeb-Simple.git diff --git a/lib/Web/Simple/DispatchParser.pm b/lib/Web/Simple/DispatchParser.pm index 2c28924..6b43316 100644 --- a/lib/Web/Simple/DispatchParser.pm +++ b/lib/Web/Simple/DispatchParser.pm @@ -19,7 +19,7 @@ sub parse_dispatch_specification { } sub _parse_spec { - my ($self, $spec) = @_; + my ($self, $spec, $nested) = @_; for ($_[1]) { my @match; local $self->{already_have}; @@ -27,10 +27,18 @@ sub _parse_spec { PARSE: { do { push @match, $self->_parse_spec_section($_) or $self->_blam("Unable to work out what the next section is"); + if (/\G\)/gc) { + $self->_blam("Found closing ) with no opening (") unless $nested; + last PARSE; + } last PARSE if (pos == length); $match[-1] = $self->_parse_spec_combinator($_, $match[-1]) or $self->_blam('No valid combinator - expected + or |'); } until (pos == length) }; # accept trailing whitespace + if ($nested and pos == length) { + pos = $nested; + $self->_blam("No closing ) found for opening ("); + } return $match[0] if (@match == 1); return sub { my $env = { %{$_[0]} }; @@ -76,6 +84,11 @@ sub _parse_spec_section { /\G\.(\*|\w+)/gc and return $self->_url_extension_match($_, $1); + + # ( + + /\G\(/gc and + return $self->_parse_spec($_, pos); } return; # () will trigger the blam in our caller }