[turba] Re: Multiline entry patch for Turba 1.2
Edward Rudd
eddie at omegaware.com
Sun Jun 15 22:06:41 PDT 2003
OK Here's a patch that puts the code into the Driver/ldap.php
I merged it with the utf8 loop as there's no need to iterate through it
another time..
now off to fixing another LDAP issue I found.....
any word on my bugzilla account?
On Sun, 15 Jun 2003 23:35:17 -0400, Chuck Hagenbuch wrote:
> Quoting Edward Rudd <eddie at omegaware.com>:
>
>> This patch fixes an issue with Turba 1.2 where it would insert a
>> Carriage Return, Line Feed instead of just Line Feed between the lines
>> of a multiline entry (ie. home address) This causes a problem with
>> Evolution where evolution will not display the entry in the address book
>> if there is a carriage return in the entry.. But the entries SHOULD
>> only have line feeds..
>
> This is an LDAP issue, right? This should probably be addressed in the
> LDAP driver, where it can be done only once. Patch?
>
> -chuck
>
> --
> Charles Hagenbuch, <chuck at horde.org>
> The alligators were there, too, in a bathtub inside the house.
--- ldap.php.orig Tue Feb 25 20:40:48 2003
+++ ldap.php Sun Jun 15 23:54:34 2003
@@ -301,14 +301,17 @@
// Don't add empty attributes.
$attributes = array_filter($attributes, array($this, 'cleanEmptyAttributes'));
- // Encode entries in UTF-8 if requested.
- if ($this->encoding == 'utf8') {
- foreach ($attributes as $key => $val) {
- if (!is_array($val)) {
- $attributes[$key] = utf8_encode($val);
- }
- }
- }
+ // fix CRLF to LF in multiline entries
+ foreach ($attributes as $key => $val) {
+ if (!is_array($val)) {
+ $val = str_replace("\r\n","\n",$val);
+ // Encode entries in UTF-8 if requested.
+ if ($this->encoding == 'utf8') {
+ $val = utf8_encode($val);
+ }
+ $attributes[$key] = $val;
+ }
+ }
if (!@ldap_add($this->ds, $dn, $attributes)) {
return new PEAR_Error('Failed to add an object: [' . ldap_errno($this->ds) . '] "' . ldap_error($this->ds) . '" (attributes: [' . serialize($attributes) . ']).');
@@ -375,14 +378,17 @@
}
}
- // Encode entries in UTF-8 if requested.
- if ($this->encoding == 'utf8') {
- foreach ($attributes as $key => $val) {
- if (!is_array($val)) {
- $attributes[$key] = utf8_encode($val);
- }
- }
- }
+ // fix CRLF to LF in multiline entries
+ foreach ($attributes as $key => $val) {
+ if (!is_array($val)) {
+ $val = str_replace("\r\n","\n",$val);
+ // Encode entries in UTF-8 if requested.
+ if ($this->encoding == 'utf8') {
+ $val = utf8_encode($val);
+ }
+ $attributes[$key] = $val;
+ }
+ }
unset($attributes[$object_key]);
$attributes = array_filter($attributes, array($this, 'cleanEmptyAttributes'));
More information about the turba
mailing list