From 6f29e4fe80fbeee9ccec401298ac44f50b5340b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20P=C3=A9rez=20Crespo?= <jaime.perez@uninett.no> Date: Thu, 11 Jul 2013 09:19:15 +0000 Subject: [PATCH] Fix for issue #555. Avoid usage of anonymous functions for backwards compatibility with PHP versions prior to 5.3. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3255 44740490-163a-0410-bde0-09ae8108e29a --- .../core/lib/Auth/Process/GenerateGroups.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/core/lib/Auth/Process/GenerateGroups.php b/modules/core/lib/Auth/Process/GenerateGroups.php index 3b4acf0bc..61db17e77 100644 --- a/modules/core/lib/Auth/Process/GenerateGroups.php +++ b/modules/core/lib/Auth/Process/GenerateGroups.php @@ -136,10 +136,24 @@ class sspmod_core_Auth_Process_GenerateGroups extends SimpleSAML_Auth_Processing assert('is_string($string)'); return preg_replace_callback('/([^a-zA-Z0-9_@=.])/', - function ($m) { return sprintf("%%%02x", ord($m[1])); }, + 'self::escapeIllegalChar', $string); } + /** + * Escapes a single special character. + * + * This function is used as a callback by escapeIllegalChars. + * + * @param array $matches The matches array provided by + * preg_*() functions. $matches[0] is the complete match, while + * $matches[1] is the specific subpattern enclosed in parenthesis + * that triggers the match. + */ + private static function escapeIllegalChar($matches) { + return sprintf("%%%02x", ord($matches[1])); + } + } -?> \ No newline at end of file +?> -- GitLab