[turba] Turba, LDAP, "$", and mapquest
Adam Tauno Williams
adam at morrison-ind.com
Sun Mar 2 13:19:18 PST 2003
>It is LDAP standard to use a "$" to represent newlines in multilined values,
>as
>RFC2252 says:
>
>6.27. Postal Address
> ( 1.3.6.1.4.1.1466.115.121.1.41 DESC 'Postal Address' )
> Values in this syntax are encoded according to the following BNF:
> postal-address = dstring *( "$" dstring )
> In the above, each dstring component of a postal address value is
> encoded as a value of type Directory String syntax. Backslashes and
> dollar characters, if they occur in the component, are quoted as
> described in section 4.3. Many servers limit the postal address to
> six lines of up to thirty characters.
> Example:
> 1234 Main St.$Anytown, CA 12345$USA
> 241,000,000 Sweepstakes$PO Box 1000000$Anytown, CA 12345$USA
>
>Is it possible to enable "$" -> "\n" translation in the Turba LDAP driver?
>I've
>noticed this for along time, but never cared. Now it pretty much breaks
>mapquest support as this appears to confuse the address parser.
A brutal way to fix this is to modify function getResults($fields, $res) in
lib/Drivers/ldap.php to look like -
$result[$field] = '';
if (!empty($entry[$field])) {
for ($j = 0; $j < $entry[$field]['count']; $j++) {
if (!empty($result[$field])) {
$result[$field] .= $this->separator;
}
if ($this->encoding == 'utf8') {
//$result[$field] .=
utf8_decode($entry[$field][$j]);
$result[$field] .= str_replace("$", "\n",
utf8_decode($entry[$field][$j]));
} else {
//$result[$field] .= $entry[$field][$j];
$result[$field] .= str_replace("$", "\n",
$entry[$field][$j]);
}
}
}
But I imagine this would break reading on non-text entries like PGP keys, JPEG
photos, etc... if someone uses those types of attributes with Turba.
Is there a way to check a fields type (if "multiline") from this point in the
code so I can only do the "$" magic in that case? And what is the easiest way
in PHP to expand the dollar sign only if it is not escaped ("\$") as in that
case we would want to leave it alone.
More information about the turba
mailing list