CGI-Untaint-date-1.00/0000755000175200017520000000000010316000017013123 5ustar tonytonyCGI-Untaint-date-1.00/t/0000755000175200017520000000000010316000017013366 5ustar tonytonyCGI-Untaint-date-1.00/t/pod.t0000644000175200017520000000020110315777216014353 0ustar tonytonyuse Test::More; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); CGI-Untaint-date-1.00/t/date.t0000644000175200017520000000102307407203121014474 0ustar tonytony#!/usr/bin/perl -Tw use Test::More tests => 5; use strict; use CGI; use CGI::Untaint; my @dates = ( "December 12, 2001", "12th December, 2001", "2001-12-12", "second Wednesday in December, 2001", ); my $count = 0; my %hash = map { "var" . ++$count => $_ } @dates; my $q = CGI->new(\%hash); ok(my $data = CGI::Untaint->new( $q->Vars ), "Can create the handler"); $count = 0; foreach (@dates) { ++$count; is $data->extract(-as_date => "var$count")->format, "2001-12-12", "$_ = 2001-12-12"; } CGI-Untaint-date-1.00/t/pod-coverage.t0000644000175200017520000000024110315777216016150 0ustar tonytonyuse Test::More; eval "use Test::Pod::Coverage 1.00"; plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@; all_pod_coverage_ok(); CGI-Untaint-date-1.00/lib/0000755000175200017520000000000010316000017013671 5ustar tonytonyCGI-Untaint-date-1.00/lib/CGI/0000755000175200017520000000000010316000017014273 5ustar tonytonyCGI-Untaint-date-1.00/lib/CGI/Untaint/0000755000175200017520000000000010316000017015715 5ustar tonytonyCGI-Untaint-date-1.00/lib/CGI/Untaint/date.pm0000644000175200017520000000405610315777651017225 0ustar tonytonypackage CGI::Untaint::date; $VERSION = '1.00'; use strict; use base 'CGI::Untaint::printable'; use Date::Manip; use Date::Simple; sub is_valid { my $self = shift; local $SIG{__WARN__} = sub {}; local *Date::Manip::Date_TimeZone = sub { 'GMT' }; Date_Init(sprintf 'DateFormat=%s' => $self->date_format); my $date = ParseDate($self->value) or return; my @date = unpack "A4A2A2", $date; my $ds = eval { Date::Simple->new(@date) } or return; $self->value($ds); return $ds; } sub date_format { 'UK' } =head1 NAME CGI::Untaint::date - validate a date =head1 SYNOPSIS use CGI::Untaint; my $handler = CGI::Untaint->new($q->Vars); my $date = $handler->extract(-as_date => 'date'); =head1 DESCRIPTION =head2 is_valid This Input Handler verifies that it is dealing with a reasonable date. Reasonably means anything that Date::Manip thinks is sensible, so you could use any of (for example): "December 12, 2001" "12th December, 2001" "2001-12-12" "next Tuesday" "third Wednesday in March" See L for much more information on what date formats are acceptable. The resulting date will be a Date::Simple object. L for more information on this. =head2 date_format By default ambiguous dates of the format 08/09/2001 will be treated as UK style (i.e. 8th September rather than 9th August) If you want to change this, subclass it and override date_format() =head1 WARNING Date::Manip does not play nicely with taint mode. In order to work around this we locally clobber Date::Manip's 'timezone' code. As we're only interested in dates rather than times, this shouldn't be much of an issue. If it is, then please let me know! =head1 SEE ALSO L. L. =head1 AUTHOR Tony Bowden =head1 BUGS and QUERIES Please direct all correspondence regarding this module to: bug-CGI-Untaint-date@rt.cpan.org =head1 COPYRIGHT and LICENSE Copyright (C) 2001-2005 Tony Bowden. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; CGI-Untaint-date-1.00/README0000644000175200017520000000304110315777714014031 0ustar tonytonyNAME CGI::Untaint::date - validate a date SYNOPSIS use CGI::Untaint; my $handler = CGI::Untaint->new($q->Vars); my $date = $handler->extract(-as_date => 'date'); DESCRIPTION is_valid This Input Handler verifies that it is dealing with a reasonable date. Reasonably means anything that Date::Manip thinks is sensible, so you could use any of (for example): "December 12, 2001" "12th December, 2001" "2001-12-12" "next Tuesday" "third Wednesday in March" See Date::Manip for much more information on what date formats are acceptable. The resulting date will be a Date::Simple object. Date::Simple for more information on this. date_format By default ambiguous dates of the format 08/09/2001 will be treated as UK style (i.e. 8th September rather than 9th August) If you want to change this, subclass it and override date_format() WARNING Date::Manip does not play nicely with taint mode. In order to work around this we locally clobber Date::Manip's 'timezone' code. As we're only interested in dates rather than times, this shouldn't be much of an issue. If it is, then please let me know! SEE ALSO Date::Simple. Date::Manip. AUTHOR Tony Bowden BUGS and QUERIES Please direct all correspondence regarding this module to: bug-CGI-Untaint-date@rt.cpan.org COPYRIGHT and LICENSE Copyright (C) 2001-2005 Tony Bowden. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. CGI-Untaint-date-1.00/Changes0000644000175200017520000000056210315777617014453 0ustar tonytonyRevision history 1.00 Mon Sep 26 13:58:49 UTC 2005 + Fix documentation for UK vs US date formats + Allow easier overriding of date format preferences 0.03 Sun Feb 3 14:22:29 GMT 2002 + The CPAN shell doesn't like my prerequisites 0.02 Sun Dec 16 20:29:34 GMT 2001 + Made taint safe. (Ironic, isn't it) 0.01 Fri Oct 26 14:46:53 BST 2001 - Created this CGI-Untaint-date-1.00/MANIFEST.SKIP0000444000175200017520000000054510315777764015060 0ustar tonytony# Avoid version control files. \bRCS\b \bCVS\b ,v$ ,B$ ,D$ \B\.svn\b aegis.log$ \bconfig$ \bbuild$ # Avoid Makemaker generated and utility files. \bMakefile$ \bblib \bMakeMaker-\d \bpm_to_blib$ \bblibdirs$ # Avoid Module::Build generated and utility files. \bBuild$ \b_build # Avoid temp and backup files. ~$ \.gz$ \.old$ \.bak$ \.swp$ \.tdy$ \#$ \b\.# CGI-Untaint-date-1.00/Makefile.PL0000644000175200017520000000073207427243725015127 0ustar tonytonyuse ExtUtils::MakeMaker; WriteMakefile( NAME => 'CGI::Untaint::date', VERSION_FROM => 'lib/CGI/Untaint/date.pm', PREREQ_PM => { CGI::Untaint => 0.07, Date::Manip => 5.00, Date::Simple => 0.01, }, ($] > 5.005 ? () : ( ABSTRACT_FROM => 'lib/CGI/Untaint/date.pm', AUTHOR => 'Tony Bowden ', )), ); CGI-Untaint-date-1.00/META.yml0000644000175200017520000000066110316000017014377 0ustar tonytony# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: CGI-Untaint-date version: 1.00 version_from: lib/CGI/Untaint/date.pm installdirs: site requires: CGI::Untaint: 0.07 Date::Manip: 5 Date::Simple: 0.01 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.17 CGI-Untaint-date-1.00/MANIFEST0000644000175200017520000000021210316000002014241 0ustar tonytonyChanges lib/CGI/Untaint/date.pm Makefile.PL MANIFEST This list of files MANIFEST.SKIP META.yml README t/date.t t/pod-coverage.t t/pod.t