From 30ed305b62ebe815b2da16acd967cfa3e920325c Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Thu, 6 May 2010 14:00:53 -0500 Subject: [PATCH] put all url validation in WebGUI::Session::Url instead of i18n --- lib/WebGUI/Session/Url.pm | 14 ++++++++++---- lib/WebGUI/i18n/English.pm | 12 ++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/WebGUI/Session/Url.pm b/lib/WebGUI/Session/Url.pm index 750b68d4a..bcc5bf8f2 100644 --- a/lib/WebGUI/Session/Url.pm +++ b/lib/WebGUI/Session/Url.pm @@ -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; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/i18n/English.pm b/lib/WebGUI/i18n/English.pm index b8abc2f78..8823777e4 100644 --- a/lib/WebGUI/i18n/English.pm +++ b/lib/WebGUI/i18n/English.pm @@ -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; }