Closed GoogleCodeExporter closed 9 years ago
It appears that URLs like /en/cat/Alkumets%E4n%20Bia%20Electra/hvc/ get routed
by / rule and go to language detection for root page.
Original comment by heikki.s...@gmail.com
on 22 Feb 2011 at 9:50
Might be a Mojolicious bug. Building a test case.
Original comment by heikki.s...@gmail.com
on 22 Feb 2011 at 9:56
A question posted to Google Groups / Mojolicious.
Strange routing behavior with some URL encoded chars
I noticed this odd behavior on Windows when routing URLs with some URL encoded
characters. Mojolicious version is 1.11. Is this a bug or could you explain
what is going on.
-- URLs and their results
http://localhost:3000/ -> bare root matched -> OK
http://localhost:3000/en/ -> matched root under a language -> OK
http://localhost:3000/en/this/that/ -> general match under a language -> OK
http://localhost:3000/en/this/1234/ -> general match under a language -> OK
http://localhost:3000/en/th%20is/ -> general match under a language -> OK
http://localhost:3000/en/th%2Bis/ -> general match under a language -> OK
http://localhost:3000/en/th%E4is/ -> bare root matched -> STRANGE
http://localhost:3000/en/th%FCis/ -> bare root matched -> STRANGE
-- /lib/Test.pm
package Test;
use strict;
use warnings;
use parent 'Mojolicious';
sub startup {
my $self = shift;
warn $Mojolicious::VERSION;
my $r = $self->routes;
$r->route('/')->to( cb => sub {
my $self = shift; $self->render( text => 'bare root matched' );
});
my $l = $r->route ('/:lang', lang => qr/(en|se|fi)/ );
$l->route( '/' )->to( cb => sub {
my $self = shift; $self->render( text => 'matched root under a language' );
});
$l->route('(*path)')->to( cb => sub {
my $self = shift; $self->render( text => 'general match under a language' );
});
}
1;
-- /script/test
#!/usr/bin/env perl
use strict;
use warnings;
use File::Basename 'dirname';
use File::Spec;
use lib join '/', File::Spec->splitdir(dirname(__FILE__)), 'lib';
use lib join '/', File::Spec->splitdir(dirname(__FILE__)), '..', 'lib';
eval 'use Mojolicious::Commands';
die <<EOF if $@;
It looks like you don't have the Mojolicious Framework installed.
Please visit http://mojolicio.us for detailed installation instructions.
EOF
$ENV{MOJO_APP} ||= 'Test';
Mojolicious::Commands->start;
-- startup at windows command line
> perl test daemon
1.11 at ../lib/Test.pm line 7.
Wed Feb 23 00:29:46 2011 info Mojo::Server::Daemon:316 [9528]:
Server listening (http://*:3000)
Server available at http://*:3000.
Original comment by heikki.s...@gmail.com
on 22 Feb 2011 at 10:49
SR gave instant answer and suggest bad lang regexp. Investigating.
Original comment by heikki.s...@gmail.com
on 23 Feb 2011 at 1:49
So far no solution found. () are forbidden in regexps but the obvious solutions
won't work either:
my $l = $r->route ('/:lang', lang => qr/[a-z][a-z]/ );
my $l = $r->route ('/:lang', lang => qr/../ );
my $l = $r->route ('/:lang', lang => qr/[a-z]+/ );
my $l = $r->route ('/:lang', lang => qr/en/ );
Original comment by heikki.s...@gmail.com
on 23 Feb 2011 at 3:35
I have now boiled it down to this minimal example. Still no idea why this is
happening. Mojolicoius 1.11 on Windows 7 64-bit.
-- URLs and their results
http://localhost:3000/simple -> simple -> OK
http://localhost:3000/longer1234 -> longer1234 -> OK
http://localhost:3000/aaa%20bbb -> aaa bbb -> OK
http://localhost:3000/aaa%24bbb -> aaa$bbb -> OK
http://localhost:3000/aaa%3Fbbb -> aaa?bbb -> OK
http://localhost:3000/aaa%E4bbb -> This page is brand new and has not been
unboxed yet! -> STRANGE
http://localhost:3000/aaa%FCbbb -> This page is brand new and has not been
unboxed yet! -> STRANGE
http://localhost:3000/aaa%DFbbb -> This page is brand new and has not been
unboxed yet! -> STRANGE
-- /lib/Test.pm
package Test;
use strict;
use warnings;
use parent 'Mojolicious';
sub startup {
my $self = shift;
warn $Mojolicious::VERSION;
my $r = $self->routes;
$r->route ('/:capture' )->to( cb => sub {
my $self = shift; $self->render(
text => $self->stash->{capture}
);
});
}
1;
-- /script/test
#!/usr/bin/env perl
use strict;
use warnings;
use File::Basename 'dirname';
use File::Spec;
use lib join '/', File::Spec->splitdir(dirname(__FILE__)), 'lib';
use lib join '/', File::Spec->splitdir(dirname(__FILE__)), '..', 'lib';
eval 'use Mojolicious::Commands';
die <<EOF if $@;
It looks like you don't have the Mojolicious Framework installed.
Please visit http://mojolicio.us for detailed installation instructions.
EOF
$ENV{MOJO_APP} ||= 'Test';
Mojolicious::Commands->start;
-- startup at windows command line
> perl test daemon
1.11 at ../lib/Test.pm line 7.
Wed Feb 23 21:19:21 2011 info Mojo::Server::Daemon:316 [3748]: Server listening
(http://*:3000)
Server available at http://*:3000.
-- routes
> perl test routes
1.11 at ../lib/Test.pm line 7.
/:capture capture (?-xism:^/([^\/\.]+))
Original comment by heikki.s...@gmail.com
on 23 Feb 2011 at 7:36
Is a Mojolicious bug. Fix is available by SR (very quick). Requires testing.
Original comment by heikki.s...@gmail.com
on 24 Feb 2011 at 6:13
Fix work OK. Done.
Original comment by heikki.s...@gmail.com
on 24 Feb 2011 at 7:42
Original issue reported on code.google.com by
heikki.s...@gmail.com
on 19 Feb 2011 at 11:27