Skip to content
Snippets Groups Projects
Commit 35e4382c authored by Olav Morken's avatar Olav Morken
Browse files

core:GenerateGroups: Fix use of "/e" preg_replace modifier.

See: https://wiki.php.net/rfc/remove_preg_replace_eval_modifier

Thanks to Thijs Kinkhorst for providing this patch!

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3223 44740490-163a-0410-bde0-09ae8108e29a
parent 819666a0
Branches
Tags
No related merge requests found
......@@ -135,11 +135,9 @@ class sspmod_core_Auth_Process_GenerateGroups extends SimpleSAML_Auth_Processing
private static function escapeIllegalChars($string) {
assert('is_string($string)');
/* Since preg_replace escapes both ["] and ['], while either of them isn't unescaped in the string
* evaluation, we need a test to catch both of them.
*/
$replacement = '("\\1" === "\\\'") ? "%27" : sprintf("%%%02x", ord("\\1"))';
return preg_replace('/([^a-zA-Z0-9_@=.])/e', $replacement, $string);
return preg_replace_callback('/([^a-zA-Z0-9_@=.])/',
function ($m) { return sprintf("%%%02x", ord($m[1])); },
$string);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment