]> Dogcows Code - chaz/p5-CGI-Ex/commitdiff
CGI::Ex 2.07 v2.07
authorPaul Seamons <perl@seamons.com>
Tue, 30 Jan 2007 00:00:00 +0000 (00:00 +0000)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Fri, 9 May 2014 23:46:40 +0000 (17:46 -0600)
17 files changed:
Changes
META.yml
lib/CGI/Ex.pm
lib/CGI/Ex/App.pm
lib/CGI/Ex/Auth.pm
lib/CGI/Ex/Conf.pm
lib/CGI/Ex/Die.pm
lib/CGI/Ex/Dump.pm
lib/CGI/Ex/Fill.pm
lib/CGI/Ex/JSONDump.pm
lib/CGI/Ex/Template.pm
lib/CGI/Ex/Template.pod
lib/CGI/Ex/Validate.pm
lib/CGI/Ex/validate.js
lib/CGI/Ex/yaml_load.js
samples/benchmark/bench_template.pl
t/7_template_00_base.t

diff --git a/Changes b/Changes
index de56ae76640d151adf416e8d19328d31039ea8f0..194f1142a40312cc8ae2f21c2ee7e9d31bf6a350 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,14 @@
+2.07   2007-01-30
+        * Add clear_app method which flushes items pertaining to navigation.
+        * Allow for CGI::Ex::Template PLUGIN_BASE to be a scalar OR an arrayref.
+        * Add sort keys to DUMP directive
+        * Add trim_control_chars as a validate directive
+        * Allow for . in the QR_PRIVATE of Template
+        * Add dump_parse_expr to CGI::Ex::Template
+        * Fix JSONDump to handle more number cases
+        * Fix JSONDump to output more IE friendly JS
+        * Allow fill to work only with form elements with attributes
+
 2.06   2006-07-21
         * Allow for JSONDump to swap --> to --"+">
         * Fix memory issue in App with closures
index 5adf0c71a7eb196e9be67ae0c7576de1791da597..05522c4513c41a2c4242799e0d94d1f0c9765ad2 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -1,10 +1,10 @@
 # http://module-build.sourceforge.net/META-spec.html
 #XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
 name:         CGI-Ex
-version:      2.06
+version:      2.07
 version_from: lib/CGI/Ex.pm
 installdirs:  site
 requires:
 
 distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
+generated_by: ExtUtils::MakeMaker version 6.30_01
index e163008cb4c3a04ccd9f15a962b85520d96a84b2..db9cda672d33cebfbf26ab996d24648ec7ea5c3f 100644 (file)
@@ -7,7 +7,7 @@ CGI::Ex - CGI utility suite - makes powerful application writing fun and easy
 =cut
 
 ###----------------------------------------------------------------###
-#  Copyright 2006 - Paul Seamons                                     #
+#  Copyright 2007 - Paul Seamons                                     #
 #  Distributed under the Perl Artistic License without warranty      #
 ###----------------------------------------------------------------###
 
@@ -24,7 +24,7 @@ use vars qw($VERSION
 use base qw(Exporter);
 
 BEGIN {
-    $VERSION               = '2.06';
+    $VERSION               = '2.07';
     $PREFERRED_CGI_MODULE  ||= 'CGI';
     @EXPORT = ();
     @EXPORT_OK = qw(get_form
@@ -1045,5 +1045,3 @@ Paul Seamons
 This module may be distributed under the same terms as Perl itself.
 
 =cut
-
-1;
index 34fdf11c9222cb40a27a8ed1666bf0b0a6944c5c..739c82fb755307e22a63d39f28257b1fd723639c 100644 (file)
@@ -2,7 +2,7 @@ package CGI::Ex::App;
 
 ###----------------------------------------------------------------###
 #  See the perldoc in CGI/Ex/App.pod
-#  Copyright 2006 - Paul Seamons                                     #
+#  Copyright 2007 - Paul Seamons                                     #
 #  Distributed under the Perl Artistic License without warranty      #
 ###----------------------------------------------------------------###
 
@@ -10,7 +10,7 @@ use strict;
 use vars qw($VERSION);
 
 BEGIN {
-    $VERSION = '2.06';
+    $VERSION = '2.07';
 
     Time::HiRes->import('time') if eval {require Time::HiRes};
     eval {require Scalar::Util};
@@ -674,6 +674,29 @@ sub stash {
     return $self->{'stash'} ||= {};
 }
 
+sub clear_app {
+    my $self = shift;
+
+    delete @{ $self }{qw(
+        cgix
+        vob
+        form
+        cookies
+        stash
+        path
+        path_i
+        history
+        __morph_lineage_start_index
+        __morph_lineage
+        hash_errors
+        hash_fill
+        hash_swap
+        hash_common
+    )};
+
+    return $self;
+}
+
 ###----------------------------------------------------------------###
 ### default hook implementations
 
index 33bdffea2a413d5ae81341b6fe5ee5368256433a..82c3964dda3e155f1feeecffe17ed6987efd9dfd 100644 (file)
@@ -7,7 +7,7 @@ CGI::Ex::Auth - Handle logins nicely.
 =cut
 
 ###----------------------------------------------------------------###
-#  Copyright 2006 - Paul Seamons                                     #
+#  Copyright 2007 - Paul Seamons                                     #
 #  Distributed under the Perl Artistic License without warranty      #
 ###----------------------------------------------------------------###
 
@@ -18,7 +18,7 @@ use MIME::Base64 qw(encode_base64 decode_base64);
 use Digest::MD5 qw(md5_hex);
 use CGI::Ex;
 
-$VERSION = '2.06';
+$VERSION = '2.07';
 
 ###----------------------------------------------------------------###
 
index 489c6b1fe7ed67b9931a8b2fc3bd34343beeab7b..8b656060ed6556306a3246ca8f8466c48e8d28e5 100644 (file)
@@ -7,7 +7,7 @@ CGI::Ex::Conf - Conf Reader/Writer for many different data format types
 =cut
 
 ###----------------------------------------------------------------###
-#  Copyright 2006 - Paul Seamons                                     #
+#  Copyright 2007 - Paul Seamons                                     #
 #  Distributed under the Perl Artistic License without warranty      #
 ###----------------------------------------------------------------###
 
@@ -25,10 +25,11 @@ use vars qw($VERSION
             %CACHE
             $HTML_KEY
             @EXPORT_OK
+            $NO_WARN_ON_FAIL
             );
 @EXPORT_OK = qw(conf_read conf_write in_cache);
 
-$VERSION = '2.06';
+$VERSION = '2.07';
 
 $DEFAULT_EXT = 'conf';
 
@@ -134,7 +135,7 @@ sub conf_read {
   ### don't die if the file is not found - do die otherwise
   if (! -e $file) {
       eval { die "Conf file $file not found" };
-      warn "Conf file $file not found" if ! $args->{'no_warn_on_fail'};
+      warn "Conf file $file not found" if ! $args->{'no_warn_on_fail'} && ! $NO_WARN_ON_FAIL;
       return;
   }
 
@@ -803,7 +804,7 @@ conf_read and conf_write method calls.
 
 =head1 FUNCTIONS
 
-=over4
+=over 4
 
 =item conf_read
 
index d9cfdb15d0d17d8660216b7f9dc1a0b5b8fddb31..14e2271c5a964220158c06e8d7d8df0ce3529dc6 100644 (file)
@@ -7,12 +7,13 @@ CGI::Ex::Die - A CGI::Carp::FatalsToBrowser type utility.
 =cut
 
 ###----------------------------------------------------------------###
-#  Copyright 2006 - Paul Seamons                                     #
+#  Copyright 2007 - Paul Seamons                                     #
 #  Distributed under the Perl Artistic License without warranty      #
 ###----------------------------------------------------------------###
 
 use strict;
-use vars qw($no_recurse
+use vars qw($VERSION
+            $no_recurse
             $EXTENDED_ERRORS $SHOW_TRACE $IGNORE_EVAL
             $ERROR_TEMPLATE
             $LOG_HANDLER $FINAL_HANDLER
@@ -22,6 +23,7 @@ use CGI::Ex;
 use CGI::Ex::Dump qw(debug ctrace dex_html);
 
 BEGIN {
+  $VERSION = '2.07';
   $SHOW_TRACE = 0      if ! defined $SHOW_TRACE;
   $IGNORE_EVAL = 0     if ! defined $IGNORE_EVAL;
   $EXTENDED_ERRORS = 1 if ! defined $EXTENDED_ERRORS;
index 0331603e1c032080abde03c97080bad5b0446204..06b806391c41a0860efc8041e386ad4226b3b620 100644 (file)
@@ -7,7 +7,7 @@ CGI::Ex::Dump - A debug utility
 =cut
 
 ###----------------------------------------------------------------###
-#  Copyright 2006 - Paul Seamons                                     #
+#  Copyright 2007 - Paul Seamons                                     #
 #  Distributed under the Perl Artistic License without warranty      #
 ###----------------------------------------------------------------###
 
@@ -17,7 +17,7 @@ use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION
 use strict;
 use Exporter;
 
-$VERSION   = '2.06';
+$VERSION   = '2.07';
 @ISA       = qw(Exporter);
 @EXPORT    = qw(dex dex_warn dex_text dex_html ctrace dex_trace);
 @EXPORT_OK = qw(dex dex_warn dex_text dex_html ctrace dex_trace debug);
index 2ae971ffc73a17b26a76fb28385aeed638687d93..25e13bee95e9928c0705166056b88c58e9a5e023 100644 (file)
@@ -7,7 +7,7 @@ CGI::Ex::Fill - Fast but compliant regex based form filler
 =cut
 
 ###----------------------------------------------------------------###
-#  Copyright 2006 - Paul Seamons                                     #
+#  Copyright 2007 - Paul Seamons                                     #
 #  Distributed under the Perl Artistic License without warranty      #
 ###----------------------------------------------------------------###
 
@@ -24,7 +24,7 @@ use vars qw($VERSION
 use base qw(Exporter);
 
 BEGIN {
-    $VERSION   = '2.06';
+    $VERSION   = '2.07';
     @EXPORT    = qw(form_fill);
     @EXPORT_OK = qw(fill form_fill html_escape get_tagval_by_key swap_tagval_by_key);
 };
@@ -185,7 +185,7 @@ sub fill {
     ### First pass
     ### swap <input > form elements if they have a name
     $$ref =~ s{
-        (<input \s (?: ([\"\'])(?:|.*?[^\\])\2 | [^>] )* >) # nested html ok
+        (<input \s (?: ([\"\'])(?:|.*?[^\\])\2 | [^>] )+ >) # nested html ok
         }{
             ### get the type and name - intentionally exlude names with nested "'
             my $tag   = $1;
@@ -249,7 +249,7 @@ sub fill {
         my $opts = substr($$ref, $start[$i], $close[$i] - $start[$i]);
         $opts =~ s{
             (<select \s                                 # opening
-             (?: "" | '' | ([\"\']).*?[^\\]\2 | [^>] )* # nested html ok
+             (?: "" | '' | ([\"\']).*?[^\\]\2 | [^>] )+ # nested html ok
              >)                                         # end of tag
             }{}sxi || next;
         next if ! $opts;
@@ -303,7 +303,7 @@ sub fill {
         my $oldval = substr($$ref, $start[$i] + $offset, $close[$i] - $start[$i]);
         $oldval =~ s{
             (<textarea \s                               # opening
-             (?: "" | '' | ([\"\']).*?[^\\]\2 | [^>] )* # nested html ok
+             (?: "" | '' | ([\"\']).*?[^\\]\2 | [^>] )+ # nested html ok
              >)                                         # end of tag
             }{}sxi || next;
         my $tag  = $1;
index 92d08379e9537d7c4b83c78528c7391a19b8b87d..03ddce970d94e995e67ece8e7d3eb15fa5a66877 100644 (file)
@@ -7,7 +7,7 @@ CGI::Ex::JSONDump - Comprehensive data to JSON dump.
 =cut
 
 ###----------------------------------------------------------------###
-#  Copyright 2006 - Paul Seamons                                     #
+#  Copyright 2007 - Paul Seamons                                     #
 #  Distributed under the Perl Artistic License without warranty      #
 ###----------------------------------------------------------------###
 
@@ -17,7 +17,7 @@ use strict;
 use base qw(Exporter);
 
 BEGIN {
-    $VERSION  = '2.06';
+    $VERSION  = '2.07';
 
     @EXPORT = qw(JSONDump);
     @EXPORT_OK = @EXPORT;
@@ -103,7 +103,7 @@ sub js_escape {
     return 'null'  if ! defined $str;
 
     ### allow things that look like numbers to show up as numbers (and those that aren't quite to not)
-    return $str if $str =~ /^ -? (?: \d{0,13} \. \d* [1-9] | \d{1,13}) $/x;
+    return $str if $str =~ /^ -? (?: [0-9]{0,13} \. \d* [1-9] | [1-9][0-9]{0,12}) $/x;
 
     my $quote = $self->{'single_quote'} ? "'" : '"';
 
@@ -228,7 +228,7 @@ include whitespace to make them more readable.
      {
        "a" : [
          1,
-         2,
+         2
        ]
      }
 
@@ -296,7 +296,7 @@ with unknown types will not be included in the javascript output.
 
 Should contain an arrayref of keys or a hashref whose keys are the
 keys to skip.  Default is unset.  Any keys of hashrefs (including
-nested hashrefs) that are in the skip_keys item will not be included
+nested hashrefs) that are listed in the skip_keys item will not be included
 in the javascript output.
 
     JSONDump({a => 1, b => 1}, {skip_keys => ['a'], pretty => 0});
@@ -319,7 +319,7 @@ be included in the javascript output.
 
 =item indent
 
-The level to indent each nested data structure level if pretty is true.  Default is "  ".
+The level to indent each nested data structure level if pretty is true.  Default is "  " (two spaces).
 
 =item hash_nl
 
@@ -336,11 +336,11 @@ The whitespace to add after each arrayref entry if pretty is true.  Default is "
 =item str_nl
 
 The whitespace to add in between newline separated strings if pretty is true or the output line is
-greater than 80 characters.  Default is "\n".
+greater than 80 characters.  Default is "\n" (if pretty is true).
 
     JSONDump("This is a long string\n"
              ."with plenty of embedded newlines\n"
-             ."and is greater than 80 characters.\n", {pretty => 1, str_nl => "\n"});
+             ."and is greater than 80 characters.\n", {pretty => 1});
 
     Would print
 
@@ -348,8 +348,16 @@ greater than 80 characters.  Default is "\n".
       +"with plenty of embedded newlines\n"
       +"and is greater than 80 characters.\n"
 
+    JSONDump("This is a long string\n"
+             ."with plenty of embedded newlines\n"
+             ."and is greater than 80 characters.\n", {pretty => 1, str_nl => ""});
+
+    Would print
+
+    "This is a long string\nwith plenty of embedded newlines\nand is greater than 80 characters.\n"
+
 If the string is less than 80 characters, or if str_nl is set to "", then the escaped
-string will be contained on a single line.
+string will be contained on a single line.  Setting pretty to 0 effectively sets str_nl equal to "".
 
 =back
 
index 773000cb1a8cf7442d276d2f383bf6fd9a907245..9adea160d20d0d366215540b157cd38638346115 100644 (file)
@@ -2,7 +2,7 @@ package CGI::Ex::Template;
 
 ###----------------------------------------------------------------###
 #  See the perldoc in CGI/Ex/Template.pod
-#  Copyright 2006 - Paul Seamons                                     #
+#  Copyright 2007 - Paul Seamons                                     #
 #  Distributed under the Perl Artistic License without warranty      #
 ###----------------------------------------------------------------###
 
@@ -39,7 +39,7 @@ use vars qw($VERSION
             );
 
 BEGIN {
-    $VERSION = '2.06';
+    $VERSION = '2.07';
 
     $PACKAGE_EXCEPTION   = 'CGI::Ex::Template::Exception';
     $PACKAGE_ITERATOR    = 'CGI::Ex::Template::Iterator';
@@ -276,7 +276,7 @@ BEGIN {
     $QR_NUM       = '(?:\d*\.\d+ | \d+) (?: [eE][+-]\d+ )?';
     $QR_AQ_NOTDOT = "(?! \\s* $QR_COMMENTS \\.)";
     $QR_AQ_SPACE  = '(?: \\s+ | \$ | (?=[;+]) )'; # the + comes into play on filenames
-    $QR_PRIVATE   = qr/^_/;
+    $QR_PRIVATE   = qr/^[_.]/;
 
     $WHILE_MAX    = 1000;
     $EXTRA_COMPILE_EXT = '.sto';
@@ -1678,6 +1678,7 @@ sub parse_DUMP {
 sub play_DUMP {
     my ($self, $ident, $node) = @_;
     require Data::Dumper;
+    local $Data::Dumper::Sortkeys  = 1;
     my $info = $self->node_info($node);
     my $out;
     my $var;
@@ -2379,38 +2380,41 @@ sub play_USE {
     pop @var; # remove the trailing '.'
 
     ### look for a plugin_base
-    my $base = $self->{'PLUGIN_BASE'} || 'Template::Plugin'; # I'm not maintaining plugins - leave that to TT
-    my $package = $self->{'PLUGINS'}->{$module} ? $self->{'PLUGINS'}->{$module}
-       : $self->{'PLUGIN_FACTORY'}->{$module} ? $self->{'PLUGIN_FACTORY'}->{$module}
-       : "${base}::${module}";
-    my $require = "$package.pm";
-    $require =~ s|::|/|g;
-
-    ### try and load the module - fall back to bare module if allowed
+    my $BASE = $self->{'PLUGIN_BASE'} || 'Template::Plugin'; # I'm not maintaining plugins - leave that to TT
     my $obj;
-    if ($self->{'PLUGIN_FACTORY'}->{$module} || eval {require $require}) {
-        my $shape   = $package->load;
-        my $context = $self->context;
-        my @args    = $args ? map { $self->play_expr($_) } @$args : ();
-        $obj = $shape->new($context, @args);
-    } elsif (lc($module) eq 'iterator') { # use our iterator if none found (TT's works just fine)
-        $obj = $PACKAGE_ITERATOR->new($args ? $self->play_expr($args->[0]) : []);
-    } elsif (my @packages = grep {lc($package) eq lc($_)} @{ $self->list_plugins({base => $base}) }) {
-        foreach my $package (@packages) {
-            my $require = "$package.pm";
-            $require =~ s|::|/|g;
-            eval {require $require} || next;
+
+    foreach my $base (ref($BASE) eq 'ARRAY' ? @$BASE : $BASE) {
+        my $package = $self->{'PLUGINS'}->{$module} ? $self->{'PLUGINS'}->{$module}
+        : $self->{'PLUGIN_FACTORY'}->{$module} ? $self->{'PLUGIN_FACTORY'}->{$module}
+        : "${base}::${module}";
+        my $require = "$package.pm";
+        $require =~ s|::|/|g;
+
+        ### try and load the module - fall back to bare module if allowed
+        if ($self->{'PLUGIN_FACTORY'}->{$module} || eval {require $require}) {
             my $shape   = $package->load;
             my $context = $self->context;
             my @args    = $args ? map { $self->play_expr($_) } @$args : ();
             $obj = $shape->new($context, @args);
-        }
-    } elsif ($self->{'LOAD_PERL'}) {
-        my $require = "$module.pm";
-        $require =~ s|::|/|g;
-        if (eval {require $require}) {
-            my @args = $args ? map { $self->play_expr($_) } @$args : ();
-            $obj = $module->new(@args);
+        } elsif (lc($module) eq 'iterator') { # use our iterator if none found (TT's works just fine)
+            $obj = $PACKAGE_ITERATOR->new($args ? $self->play_expr($args->[0]) : []);
+        } elsif (my @packages = grep {lc($package) eq lc($_)} @{ $self->list_plugins({base => $base}) }) {
+            foreach my $package (@packages) {
+                my $require = "$package.pm";
+                $require =~ s|::|/|g;
+                eval {require $require} || next;
+                my $shape   = $package->load;
+                my $context = $self->context;
+                my @args    = $args ? map { $self->play_expr($_) } @$args : ();
+                $obj = $shape->new($context, @args);
+            }
+        } elsif ($self->{'LOAD_PERL'}) {
+            my $require = "$module.pm";
+            $require =~ s|::|/|g;
+            if (eval {require $require}) {
+                my @args = $args ? map { $self->play_expr($_) } @$args : ();
+                $obj = $module->new(@args);
+            }
         }
     }
     if (! defined $obj) {
@@ -3014,6 +3018,13 @@ sub filter_redirect {
 ###----------------------------------------------------------------###
 
 sub dump_parse {
+    my $obj = UNIVERSAL::isa($_[0], __PACKAGE__) ? shift : __PACKAGE__->new;
+    my $str = shift;
+    require Data::Dumper;
+    return Data::Dumper::Dumper($obj->parse_tree(\$str));
+}
+
+sub dump_parse_expr {
     my $obj = UNIVERSAL::isa($_[0], __PACKAGE__) ? shift : __PACKAGE__->new;
     my $str = shift;
     require Data::Dumper;
index cbfde4bf42631b29f076f77dae9b55cd6d0ccc13..7cdd753a6f40b6adb73d987a25cde897c950160a 100644 (file)
@@ -499,7 +499,7 @@ If the value of a variable is an object, methods can be called using the "." ope
 
     [% cet %]
 
-    [% cet.dump_parse('1 + 2').replace('\s+', ' ') %]
+    [% cet.dump_parse_expr('1 + 2').replace('\s+', ' ') %]
 
 Would print something like:
 
@@ -795,7 +795,7 @@ Similar to format.  Returns a string formatted with the passed pattern.  Default
 =item format
 
     [% item.format('%d') %] Print the string out in the specified format.  It is similar to
-    the "as" virtual method, except that the item is split on newline and each line is
+    the "fmt" virtual method, except that the item is split on newline and each line is
     processed separately.
 
 =item hash
@@ -1816,7 +1816,7 @@ file).
 
     # The LOAD_PERL directive should be set to 1
     [% USE cet = CGI::Ex::Template %]
-    [%~ cet.dump_parse('2 * 3').replace('\s+', ' ') %]
+    [%~ cet.dump_parse_expr('2 * 3').replace('\s+', ' ') %]
 
 Would print:
 
@@ -2095,7 +2095,7 @@ to the operation of the left hand side and right (clear as mud).
 In order to not conflict with SET, FOREACH and other operations, this
 operator is only available in parenthesis.
 
-   [% a = 2 %][%  a += 3  %] --- [% a %]    => --- 5   # is was handled by SET
+   [% a = 2 %][%  a += 3  %] --- [% a %]    => --- 5   # is handled by SET
    [% a = 2 %][% (a += 3) %] --- [% a %]    => 5 --- 5
 
 =item C<=>
@@ -2104,7 +2104,7 @@ Assignment - right associative.  Sets the left-hand side to the value of the rig
 to not conflict with SET, FOREACH and other operations, this operator is only
 available in parenthesis.  Returns the value of the righthand side.
 
-   [%  a = 1  %] --- [% a %]    => --- 1   # is was handled by SET
+   [%  a = 1  %] --- [% a %]    => --- 1   # is handled by SET
    [% (a = 1) %] --- [% a %]    => 1 --- 1
 
 =item C<not  NOT>
@@ -2440,7 +2440,8 @@ See the USE directive for more information.
 
 Default value is Template::Plugin.  The base module namespace
 that template plugins will be looked for.  See the USE directive
-for more information.
+for more information.  May be either a single namespace, or an arrayref
+of namespaces.
 
 =item POST_CHOMP
 
@@ -2676,12 +2677,12 @@ Some notes on the parsing.
 
 The following perl can be typed at the command line to view the parsed variable tree:
 
-    perl -e 'use CGI::Ex::Template; print CGI::Ex::Template::dump_parse("foo.bar + 2")."\n"'
+    perl -e 'use CGI::Ex::Template; print CGI::Ex::Template::dump_parse_expr("foo.bar + 2")."\n"'
 
 Also the following can be included in a template to view the output in a template:
 
     [% USE cet = CGI::Ex::Template %]
-    [%~ cet.dump_parse('foo.bar + 2').replace('\s+', ' ') %]
+    [%~ cet.dump_parse_expr('foo.bar + 2').replace('\s+', ' ') %]
 
 
 =head1 SEMI PUBLIC METHODS
@@ -2693,6 +2694,10 @@ may be re-implemented by subclasses of CET.
 
 =item C<dump_parse>
 
+This method allows for returning a Data::Dumper dump of a parsed template.  It is mainly used for testing.
+
+=item C<dump_parse_expr>
+
 This method allows for returning a Data::Dumper dump of a parsed variable.  It is mainly used for testing.
 
 =item C<exception>
index 55709d528f896c67100b18dd3513ee92e37a8ed6..9299a5e916a80042f0040a7bca5054a783ae2982 100644 (file)
@@ -7,7 +7,7 @@ CGI::Ex::Validate - another form validator - but it does javascript in parallel
 =cut
 
 ###----------------------------------------------------------------###
-#  Copyright 2006 - Paul Seamons                                     #
+#  Copyright 2007 - Paul Seamons                                     #
 #  Distributed under the Perl Artistic License without warranty      #
 ###----------------------------------------------------------------###
 
@@ -22,7 +22,7 @@ use vars qw($VERSION
             @UNSUPPORTED_BROWSERS
             );
 
-$VERSION = '2.06';
+$VERSION = '2.07';
 
 $DEFAULT_EXT   = 'val';
 $QR_EXTRA      = qr/^(\w+_error|as_(array|string|hash)_\w+|no_\w+)/;
@@ -303,6 +303,11 @@ sub validate_buddy {
       $value =~ s/\s+$//;
       $modified = 1;
     }
+    if ($field_val->{'trim_control_chars'}) {
+      $value =~ y/\t/ /;
+      $value =~ y/\x00-\x1F//d;
+      $modified = 1;
+    }
     if ($field_val->{'to_upper_case'}) { # uppercase
       $value = uc($value);
       $modified = 1;
@@ -1721,6 +1726,13 @@ not trim.
 
     {field => 'foo', do_not_trim => 1}
 
+=item C<trim_control_chars>
+
+Off by default.  If set to true, removes characters in the
+\x00 to \x31 range (Tabs are translated to a single space).
+
+    {field => 'foo', trim_control_chars => 1}
+
 =item C<replace>
 
 Pass a swap pattern to change the actual value of the form.
index d8a62704c4bfdfe04b9ac0f212f0187d46e5fe94..124cad9dc00bfa64bd4f2f6009af8445f8c76c8a 100644 (file)
@@ -1,10 +1,10 @@
 /**----------------------------------------------------------------***
-*  Copyright 2006 - Paul Seamons                                     *
+*  Copyright 2007 - Paul Seamons                                     *
 *  Distributed under the Perl Artistic License without warranty      *
 *  Based upon CGI/Ex/Validate.pm v1.14 from Perl                     *
 *  For instructions on usage, see perldoc of CGI::Ex::Validate       *
 ***----------------------------------------------------------------**/
-// $Revision: 1.36 $
+// $Revision: 1.38 $
 
 function Validate () {
  this.error             = vob_error;
@@ -303,6 +303,8 @@ function vob_validate_buddy (form, field, field_val, N_level, ifs_match) {
    if (typeof(values[i]) == 'undefined') continue;
    if (! this.filter_types('do_not_trim',types).length)
      values[i] = values[i].replace('^\\s+','').replace(new RegExp('\\s+$',''),'');
+   if (this.filter_types('trim_control_chars',types).length)
+     values[i] = values[i].replace(new RegExp('\t', 'g'),' ').replace(new RegExp('[^\x00-\x1F]+','g'),'');
    if (this.filter_types('to_upper_case',types).length) {
      values[i] = values[i].toUpperCase();
    } else if (this.filter_types('to_lower_case',types).length) {
index d7c427a5f57470439d70314a6fbbb226db5951ca..42617f83aff12b22933cf2c5a64a88a481da5a4b 100644 (file)
@@ -1,10 +1,10 @@
 /**----------------------------------------------------------------***
-*  Copyright 2006 - Paul Seamons                                     *
+*  Copyright 2007 - Paul Seamons                                     *
 *  Distributed under the Perl Artistic License without warranty      *
 *  Based upon YAML.pm v0.35 from Perl                                *
 ***----------------------------------------------------------------**/
 
-// $Revision: 1.17 $
+// $Revision: 1.18 $
 
 // allow for missing methods in ie 5.0
 
index 7b48028a0deb5e232f6942d60c62616b7cb1aeb0..6b0f77b9548a786f7ba69ed848db56fb7aeb76d9 100644 (file)
@@ -44,8 +44,9 @@ my @config1 = (STASH => $s, ABSOLUTE => 1, CONSTANTS => {simple => 'var'}, EVAL_
 #push @config1, (INTERPOLATE => 1);
 my @config2 = (@config1, COMPILE_EXT => '.ttc');
 
-#use CGI::Ex::Template209;
-#my $tt1 = CGI::Ex::Template209->new(@config1);
+#use CGI::Ex::Template::XS;
+#my $tt1 = CGI::Ex::Template::XS->new(@config1);
+#my $tt2 = CGI::Ex::Template::XS->new(@config2);
 my $tt1 = Template->new(@config1);
 my $tt2 = Template->new(@config2);
 
index 9481952e0730f39e60e6939ae8707db3e8744b74..7fa643b5c0ac333018d9cd3569fa824110a56427 100644 (file)
@@ -14,7 +14,7 @@ BEGIN {
 };
 
 use strict;
-use Test::More tests => 514 - ($is_tt ? 103 : 0);
+use Test::More tests => 515 - ($is_tt ? 103 : 0);
 use Data::Dumper qw(Dumper);
 use constant test_taint => 0 && eval { require Taint::Runtime };
 
@@ -374,7 +374,7 @@ process_ok('[% a = Hash.new("one", "ONE") %][% a.one %]' => 'ONE') if ! $is_tt;
 process_ok('[% a = Hash.new(one = "ONE") %][% a.one %]' => 'ONE') if ! $is_tt;
 process_ok('[% a = Hash.new(one => "ONE") %][% a.one %]' => 'ONE') if ! $is_tt;
 
-process_ok('[% {a => 1, b => 2} | Hash.keys | List.join(", ") %]' => 'a, b');
+process_ok('[% {a => 1, b => 2} | Hash.keys | List.join(", ") %]' => 'a, b') if ! $is_tt;
 
 ###----------------------------------------------------------------###
 ### chomping
@@ -729,6 +729,9 @@ process_ok("[% USE d.d = Foo(bar = 'baz') %]one[% d.d.bar %]" => '', {tt_config
 process_ok("[% USE a(bar = 'baz') %]one[% a.seven %]" => '',     {tt_config => [@config_p, PLUGINS => {a=>'Foo'}, ]});
 process_ok("[% USE a(bar = 'baz') %]one[% a.seven %]" => 'one7', {tt_config => [@config_p, PLUGINS => {a=>'Foo2'},]});
 
+@config_p = (PLUGIN_BASE => ['NonExistant', 'MyTestPlugin'], LOAD_PERL => 1);
+process_ok("[% USE Foo %]one" => 'one', {tt_config => \@config_p});
+
 ###----------------------------------------------------------------###
 ### macro
 
This page took 0.049195 seconds and 4 git commands to generate.