[Tickets #11199] problem in authusername hook example

bugs at horde.org bugs at horde.org
Thu May 17 09:49:43 UTC 2012


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: http://bugs.horde.org/ticket/11199
------------------------------------------------------------------------------
  Ticket             | 11199
  Created By         | mmalabotta at units.it
  Summary            | problem in authusername hook example
  Queue              | Horde Groupware Webmail Edition
  Version            | 4.0.6
  Type               | Bug
  State              | Unconfirmed
  Priority           | 1. Low
  Milestone          |
  Patch              |
  Owners             |
------------------------------------------------------------------------------


mmalabotta at units.it (2012-05-17 09:49) wrote:

I think there is an error in one of the authusername hook examples in  
config/hooks.php

In git, file horde/horde/config/hooks.php.dist lines 435-447:
//        // Example #1: Append the virtual domain to the username.
//        // ex. $HTTP_HOST = 'mail.mydomain.com', $userId = 'myname' returns:
//        // 'myname at mydomain.com'
//        $vdomain = preg_replace('|^mail\.|i', '', getenv('HTTP_HOST'));
//        $vdomain = Horde_String::lower($vdomain);
//
//        if ($toHorde) {
//            return $userId . '@' . $vdomain;
//        } else {
//            return (substr($userId, -strlen($vdomain)) == $vdomain)
//              ? substr($userId, 0, -strlen($vdomain))
//              : $userId;
//        }

This correctly converts "myuserid" into "myuserid at domain.com", but the  
reverse conversion is wrong, from "myuserid at domain.com" this returns  
"myuserid@".

This is a problem because (at least) it breaks some module actions:  
for example I started noticing it when trying to change permissions on  
kronolith calendars - whithout user intervention to manually modify  
the displayed usernames, the shares break, multiplying themselves.

Changing line 445 from
//              ? substr($userId, 0, -strlen($vdomain))
to
//              ? substr($userId, 0, -(strlen($vdomain)+1))
should fix it.

Massimo Malabotta





More information about the bugs mailing list