6.0.0-beta1
7/6/25

[#11199] problem in authusername hook example
Summary problem in authusername hook example
Queue Horde Groupware Webmail Edition
Queue Version 4.0.6
Type Bug
State Resolved
Priority 1. Low
Owners jan (at) horde (dot) org
Requester mmalabotta (at) units (dot) it
Created 05/17/2012 (4798 days ago)
Due
Updated 05/22/2012 (4793 days ago)
Assigned
Resolved 05/17/2012 (4798 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
05/22/2012 09:54:42 PM Git Commit Comment #3 Reply to this comment
Changes have been made in Git (develop):

commit ac24199f3456141a4e648967b8fc9d4e0ca40672
Author: Jan Schneider <jan@horde.org>
Date:   Thu May 17 18:28:39 2012 +0200

     Fix example (Bug #11199).

  horde/config/hooks.php.dist |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

http://git.horde.org/horde-git/-/commit/ac24199f3456141a4e648967b8fc9d4e0ca40672
05/17/2012 04:30:18 PM Jan Schneider Assigned to Jan Schneider
State ⇒ Resolved
 
05/17/2012 04:30:10 PM Git Commit Comment #2 Reply to this comment
Changes have been made in Git (master):

commit ac24199f3456141a4e648967b8fc9d4e0ca40672
Author: Jan Schneider <jan@horde.org>
Date:   Thu May 17 18:28:39 2012 +0200

     Fix example (Bug #11199).

  horde/config/hooks.php.dist |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

http://git.horde.org/horde-git/-/commit/ac24199f3456141a4e648967b8fc9d4e0ca40672
05/17/2012 09:49:43 AM mmalabotta (at) units (dot) it Comment #1
Priority ⇒ 1. Low
Patch ⇒ No
Milestone ⇒
Queue ⇒ Horde Groupware Webmail Edition
Summary ⇒ problem in authusername hook example
Type ⇒ Bug
State ⇒ Unconfirmed
Reply to this comment
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@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@domain.com", but the 
reverse conversion is wrong, from "myuserid@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

Saved Queries