Commit 4fdc9861 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixes #4610 Respect RFC4517 for postalAddress syntax

parent a4a1892e
......@@ -99,7 +99,7 @@ class department extends simplePlugin
new StringAttribute(
_('Country'), _('Country'), 'co', FALSE
),
new TextAreaAttribute(
new PostalAddressAttribute(
_('Address'), sprintf(_('A postal address for this %s'), $name),
'postalAddress', FALSE
),
......
......@@ -233,6 +233,42 @@ class UserPasswordAttribute extends CompositeAttribute
}
}
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;
}
function computeLdapValue ()
{
return preg_replace("/\n/", '$', addcslashes($this->getValue(), '$\\'));
}
}
class user extends simplePlugin
{
var $objectclasses = array('inetOrgPerson','organizationalPerson','person');
......@@ -308,7 +344,7 @@ class user extends simplePlugin
_('State'), _('State'),
'st', FALSE
),
new TextAreaAttribute (
new PostalAddressAttribute (
_('Address'), _('Business postal address'),
'postalAddress', FALSE
),
......@@ -366,7 +402,7 @@ class user extends simplePlugin
_('Display name'), _('Name this user should appear as. Used by Exchange.'),
'displayName', FALSE
),
new TextAreaAttribute (
new PostalAddressAttribute (
_('Home address'), _('Home postal address'),
'homePostalAddress', FALSE
),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment