Skip Menu |

This queue is for tickets about the Catalyst-Plugin-Static-Simple CPAN distribution.

Report information
The Basics
Id: 23855
Status: resolved
Priority: 0/
Queue: Catalyst-Plugin-Static-Simple

People
Owner: Nobody in particular
Requestors: ddascalescu+perl [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



In prepare_action(), the $dir variable should have its metacharacters quoted before being turned into a regexp. Not doing so can cause problems, in particular with backslashes in directory names on Windows. Patch attached, Vlad Dan Dascalescu
Subject: Static-Simple_quotemeta_patch.diff
--- Simple.pm Wed Jul 05 09:34:47 2006 +++ Simple.vlad Thu Dec 07 23:12:52 2006 @@ -23,9 +23,10 @@ # is the URI in a static-defined path? foreach my $dir ( @{ $c->config->{static}->{dirs} } ) { - my $re = ( $dir =~ /^qr\//xms ) ? eval $dir : qr/^${dir}/; + my $dir_re = quotemeta $dir; + my $re = ( $dir =~ /^qr\//xms ) ? eval $dir : qr/^${dir_re}/; if ($@) { - $c->error( "Error compiling static dir regex '$dir': $@" ); + $c->error( "Error compiling static dir regex '$dir_re': $@" ); } if ( $path =~ $re ) { if ( $c->_locate_static_file( $path ) ) {
From: AGRUNDMA [...] cpan.org
On Fri Dec 08 02:19:25 2006, dandv wrote: Show quoted text
> In prepare_action(), the $dir variable should have its metacharacters > quoted before being turned into a regexp. Not doing so can cause > problems, in particular with backslashes in directory names on Windows.
Are backslashes the only problem? Can't you use forward slashes on Windows?
Subject: http://perldoc.perl.org/perlre.html#Regular-Expressions
From: ddascalescu+perl [...] gmail.com
On Fri Dec 08 10:00:03 2006, AGRUNDMA wrote: Show quoted text
> On Fri Dec 08 02:19:25 2006, dandv wrote:
> > In prepare_action(), the $dir variable should have its metacharacters > > quoted before being turned into a regexp. Not doing so can cause > > problems, in particular with backslashes in directory names on Windows.
> > Are backslashes the only problem? Can't you use forward slashes on
Windows? I'm surprised to see this reply from you, seeing that you wrote so much Perl (http://search.cpan.org/~agrundma/) No, backslashes aren't the only problem. Any metacharacter will make the regexp work differently from what was intended. Anything supplied by the user as a literal string must be quotemeta'ed if it's going to be used in a regexp, no excuses. An while I could use forward slashes in Windows, path_to() uses backslashes.
Thanks, fixed in 0.15.