[Jifty-commit] r3692 - in Jifty-DBI/trunk: lib/Jifty/DBI/Filter

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sat Jul 14 00:06:19 EDT 2007


Author: jesse
Date: Sat Jul 14 00:06:17 2007
New Revision: 3692

Modified:
   Jifty-DBI/trunk/   (props changed)
   Jifty-DBI/trunk/META.yml
   Jifty-DBI/trunk/lib/Jifty/DBI/Filter/DateTime.pm

Log:
 r60634 at pinglin:  jesse | 2007-07-13 20:14:44 -0400
 * Additional  bulletproofing to stop jifty from trying to insert a bogus date into the database.


Modified: Jifty-DBI/trunk/META.yml
==============================================================================
--- Jifty-DBI/trunk/META.yml	(original)
+++ Jifty-DBI/trunk/META.yml	Sat Jul 14 00:06:17 2007
@@ -36,4 +36,4 @@
   YAML::Syck: 0
   perl: 5.8.3
   version: 0
-version: 0.41
+version: 0.42

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Filter/DateTime.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Filter/DateTime.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Filter/DateTime.pm	Sat Jul 14 00:06:17 2007
@@ -26,8 +26,10 @@
 =head2 encode
 
 If value is DateTime object then converts it into ISO format
-C<YYYY-MM-DD hh:mm:ss>. Does nothing if value is not defined or
-string.
+C<YYYY-MM-DD hh:mm:ss>. Does nothing if value is not defined.
+
+Sets the value to undef if the value is a string and doesn't match an ISO date (at least).
+
 
 =cut
 
@@ -35,10 +37,15 @@
     my $self = shift;
 
     my $value_ref = $self->value_ref;
-    return unless $$value_ref;
 
-    return unless UNIVERSAL::isa( $$value_ref, 'DateTime' );
+    if  ( ! UNIVERSAL::isa( $$value_ref, 'DateTime' )) {
+        if ( $$value_ref !~ /^\d{4}[ -]?\d{2}[ -]?[\d{2}]/) {
+       $$value_ref = undef;
+        }
+        return undef;
+   }
 
+    return unless $$value_ref;
     if (my $tz = $self->_time_zone) {
 	$$value_ref = $$value_ref->clone;
 	$$value_ref->time_zone('floating');


More information about the Jifty-commit mailing list