[Templates-cvs] cvs commit: Template2/lib/Template Filters.pm
cvs@template-toolkit.org
cvs@template-toolkit.org
cvs 06/05/30 07:39:23
Modified: lib/Template Filters.pm
Log:
* fixed the URI filter to bring it in line with what URI::Escape
does now
Revision Changes Path
2.84 +11 -13 Template2/lib/Template/Filters.pm
Index: Filters.pm
===================================================================
RCS file: /template-toolkit/Template2/lib/Template/Filters.pm,v
retrieving revision 2.83
retrieving revision 2.84
diff -u -r2.83 -r2.84
--- Filters.pm 2006/05/29 08:53:04 2.83
+++ Filters.pm 2006/05/30 07:39:23 2.84
@@ -17,7 +17,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: Filters.pm,v 2.83 2006/05/29 08:53:04 abw Exp $
+# $Id: Filters.pm,v 2.84 2006/05/30 07:39:23 abw Exp $
#
#============================================================================
@@ -26,10 +26,10 @@
use strict;
use warnings;
use locale;
-use base 'Template::Base'
+use base 'Template::Base';
use Template::Constants;
-our $VERSION = sprintf("%d.%02d", q$Revision: 2.83 $ =~ /(\d+)\.(\d+)/);
+our $VERSION = sprintf("%d.%02d", q$Revision: 2.84 $ =~ /(\d+)\.(\d+)/);
#------------------------------------------------------------------------
@@ -81,6 +81,7 @@
our $PLUGIN_FILTER = 'Template::Plugin::Filter';
+
#========================================================================
# -- PUBLIC METHODS --
#========================================================================
@@ -259,23 +260,20 @@
# uri_filter() [% FILTER uri %]
#
# URI escape a string. This code is borrowed from Gisle Aas' URI::Escape
-# module. For something so simple, I can't see any validation in making
-# the user install the URI modules just for this, so we cut and paste.
-#
-# URI::Escape is Copyright 1995-2000 Gisle Aas.
+# module, copyright 1995-2004. See RFC2396 for details.
#------------------------------------------------------------------------
+# cache of escaped characters
+our $URI_ESCAPES;
+
sub uri_filter {
my $text = shift;
- # construct and cache a lookup table for escapes (faster than
- # doing a sprintf() for every character in every string each
- # time)
$URI_ESCAPES ||= {
map { ( chr($_), sprintf("%%%02X", $_) ) } (0..255),
};
- $text =~ s/([^;\/?:@&=+\$,A-Za-z0-9\-_.!~*'()])/$URI_ESCAPES->{$1}/g;
+ $text =~ s/([^A-Za-z0-9\-_.!~*'()])/$URI_ESCAPES->{$1}/g;
$text;
}
@@ -1224,8 +1222,8 @@
=head1 VERSION
-2.81, distributed as part of the
-Template Toolkit version 2.15, released on 26 May 2006.
+2.83, distributed as part of the
+Template Toolkit version 2.15a, released on 29 May 2006.
=head1 COPYRIGHT