put all url validation in WebGUI::Session::Url instead of i18n

This commit is contained in:
Graham Knop 2010-05-06 14:00:53 -05:00
parent cc7b3fe3ef
commit 30ed305b62
2 changed files with 12 additions and 14 deletions

View file

@ -398,10 +398,16 @@ The string to make compliant. This is usually a page title or a filename.
=cut
sub makeCompliant {
my $self = shift;
my $url = shift;
my $i18n = WebGUI::International->new($self->session);
return $i18n->makeUrlCompliant($url);
my $self = shift;
my $url = shift;
$url =~ s{^\s+}{}; # remove leading whitespace
$url =~ s{\s+$}{}; # remove trailing whitespace
$url =~ s{^/+}{}; # remove leading slashes
$url =~ s{/+$}{}; # remove trailing slashes
$url =~ s{[^\w/:._-]+}{-}g; # replace anything aside from word or other allowed characters with dashes
$url =~ s{//+}{/}g; # remove double slashes
$url =~ s{--+}{-}g; # remove double dashes
return $url;
}
#-------------------------------------------------------------------

View file

@ -11,16 +11,8 @@ our $LANGUAGE = {
};
sub makeUrlCompliant {
my $value = shift;
$value =~ s/\s+$//; #removes trailing whitespace
$value =~ s/^\s+//; #removes leading whitespace
$value =~ s/ /-/g; #replaces whitespace with hyphens
$value =~ s/\.$//; #removes trailing period
$value =~ s/[^\w\-\.\_\/]//g; #removes characters that would interfere with the url
$value =~ s/^\///; #removes a leading /
$value =~ s/\/$//; #removes a trailing /
$value =~ s/\/\//\//g; #removes double /
return $value;
my $url = shift;
return $url;
}