Forward port urlize changes, and tests.

This commit is contained in:
Colin Kuskie 2009-06-10 03:34:09 +00:00
parent 8892b51b73
commit 1441fe2e88
2 changed files with 16 additions and 11 deletions

View file

@ -516,7 +516,7 @@ sub unescape {
=head2 urlize ( string )
Returns a url that is safe for WebGUI pages. Strings are lower-cased, run through
$self->makeCompliant and then have any trailing slashes removed.
$self->makeCompliant and then have any relative segments and trailing slashes removed.
=head3 string
@ -525,17 +525,17 @@ The string to urlize.
=cut
sub urlize {
my $self = shift;
my ($value);
$value = lc(shift); #lower cases whole string
$value = $self->makeCompliant($value);
my $self = shift;
my ($value);
$value = lc(shift); #lower cases whole string
$value = $self->makeCompliant($value);
# remove /./ or /../
$value =~ s{(^|/)\.\.?/}{$1};
$value =~ s{(^|/)(?:\.\.?/)*}{$1}g;
# remove trailing slashes
$value =~ s/\/$//;
return $value;
$value =~ s/\/$//;
return $value;
}