From 607480339f33a4e3703f8d816a3b461cfb0ec97d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come.bernigaud@opensides.be> Date: Thu, 17 Mar 2016 11:26:14 +0100 Subject: [PATCH] Fixes #4610 Fixed postalAddress special handling --- plugins/personal/generic/class_user.inc | 39 +++++++++---------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index 947fe0278..495350b53 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -237,35 +237,24 @@ class PostalAddressAttribute extends TextAreaAttribute { function inputValue ($ldapValue) { - $string = $ldapValue; - $offset = 0; - $lastslash = NULL; - while (preg_match('/[\\\$]/', $string, $m, PREG_OFFSET_CAPTURE, $offset)) { - $offset = $m[0][1] + 1; - if ($m[0][0] == '\\') { - if ($lastslash == $m[0][1] - 1) { - $string = substr_replace($string, '\\', $m[0][1] - 1, 2); - $offset = $m[0][1]; - $lastslash = NULL; - } else { - $lastslash = $m[0][1]; - } - } elseif ($m[0][0] == '$') { - if ($lastslash == $m[0][1] - 1) { - $string = substr_replace($string, '$', $m[0][1] - 1, 2); - $offset = $m[0][1]; - } else { - $string = substr_replace($string, "\n", $m[0][1], 1); - $offset = $m[0][1]; - } - } - } - return $string; + return str_replace( + array('$', '\24','\5C'), + array("\n", '$', '\\'), + $ldapValue + ); } function computeLdapValue () { - return str_replace(array("\r\n", "\n", "\r"), '$', addcslashes($this->getValue(), '$\\')); + return str_replace( + array("\r\n", "\n", "\r"), + '$', + str_replace( + array('\\', '$'), + array('\5C','\24'), + $this->getValue() + ) + ); } } -- GitLab