From 0c9bab368d05d912f8d1e660c4852a5b422764c6 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Thu, 17 Jan 2008 14:48:33 +0000
Subject: [PATCH] Allow timestamps with arbitrary precision.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@171 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/Utilities.php | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index b8b26bf7b..b4c26510e 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -227,7 +227,8 @@ class SimpleSAML_Utilities {
 
 
 	/* This function converts a SAML2 timestamp on the form
-	 * yyyy-mm-ddThh:mm:ssZ to a UNIX timestamp.
+	 * yyyy-mm-ddThh:mm:ss(\.s+)?Z to a UNIX timestamp. The sub-second
+	 * part is ignored.
 	 *
 	 * Andreas comments:
 	 *  I got this timestamp from Shibboleth 1.3 IdP: 2008-01-17T11:28:03.577Z
@@ -247,7 +248,7 @@ class SimpleSAML_Utilities {
 
 		/* We use a very strict regex to parse the timestamp. */
 		if(preg_match('/^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)' .
-		              'T(\\d\\d):(\\d\\d):(\\d\\d)(\.\\d{1,3})?Z$/D',
+		              'T(\\d\\d):(\\d\\d):(\\d\\d)(?:\\.\\d+)?Z$/D',
 		              $time, $matches) == 0) {
 			throw new Exception(
 				'Invalid SAML2 timestamp passed to' .
-- 
GitLab