From 0a0c1a1b51a4927f418481b182066c937f6df9d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Thu, 17 Jan 2008 11:39:02 +0000
Subject: [PATCH] Fix bug with timestamp handling when shibboleth is sending
 microseconds... Also some missing commas in the config template

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@168 44740490-163a-0410-bde0-09ae8108e29a
---
 config/config-template.php   | 4 ++--
 lib/SimpleSAML/Utilities.php | 8 +++++++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/config/config-template.php b/config/config-template.php
index c9980eb97..dfb80660c 100644
--- a/config/config-template.php
+++ b/config/config-template.php
@@ -123,10 +123,10 @@ $config = array (
 	 */
 	'auth.radius.hostname'        => 'radius.example.org',
 	'auth.radius.port'            => '1812',
-	'auth.radius.secret'          => 'topsecret'
+	'auth.radius.secret'          => 'topsecret',
 	'auth.radius.URNForUsername'  => 'urn:mace:dir:attribute-def:eduPersonPrincipalName',
 	'auth.radius.vendor'          => '23735',
-	'auth.radius.vendor-attr'     => '4'
+	'auth.radius.vendor-attr'     => '4',
 
 	
 	/*
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index 163cc1322..b8b26bf7b 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -229,6 +229,12 @@ class SimpleSAML_Utilities {
 	/* This function converts a SAML2 timestamp on the form
 	 * yyyy-mm-ddThh:mm:ssZ to a UNIX timestamp.
 	 *
+	 * Andreas comments:
+	 *  I got this timestamp from Shibboleth 1.3 IdP: 2008-01-17T11:28:03.577Z
+	 *  Therefore I added to possibliity to have microseconds to the format.
+	 * Added: (\.\\d{1,3})? to the regex.
+	 *
+	 *
 	 * Parameters:
 	 *  $time     The time we should convert.
 	 *
@@ -241,7 +247,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)Z$/D',
+		              'T(\\d\\d):(\\d\\d):(\\d\\d)(\.\\d{1,3})?Z$/D',
 		              $time, $matches) == 0) {
 			throw new Exception(
 				'Invalid SAML2 timestamp passed to' .
-- 
GitLab