X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FUtils.pm;h=4e5571e1536dc1384886fbb2018a3a3b02625041;hp=62b8446326bdeee31246b49f8280a179777ed5e5;hb=059c085bfcead450e70ace9ef193aa99ac2ab37d;hpb=dd91afb57b7ab0cedad388f633dd0047c2290c1f diff --git a/lib/Catalyst/Utils.pm b/lib/Catalyst/Utils.pm index 62b8446..4e5571e 100644 --- a/lib/Catalyst/Utils.pm +++ b/lib/Catalyst/Utils.pm @@ -171,8 +171,9 @@ sub home { # clean up relative path: # MyApp/script/.. -> MyApp - my ($lastdir) = $home->dir_list( -1, 1 ); - if ( $lastdir eq '..' ) { + my $dir; + my @dir_list = $home->dir_list(); + while (($dir = pop(@dir_list)) && $dir eq '..') { $home = dir($home)->parent->parent; } @@ -251,6 +252,12 @@ sub ensure_class_loaded { croak "Malformed class Name $class" if $class =~ m/(?:\b\:\b|\:{3,})/; + croak "Malformed class Name $class" + if $class =~ m/[^\w:]/; + + croak "ensure_class_loaded should be given a classname, not a filename ($class)" + if $class =~ m/\.pm$/; + return if !$opts->{ ignore_loaded } && Class::Inspector->loaded( $class ); # if a symbol entry exists we don't load again @@ -258,7 +265,9 @@ sub ensure_class_loaded { my $error; { local $@; - eval "require $class"; + my $file = $class . '.pm'; + $file =~ s{::}{/}g; + eval { CORE::require($file) }; $error = $@; }