Changeset 1004407 in github


Ignore:
Timestamp:
Dec 23, 2009 9:09:36 AM (3 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
5e3d6c2
Parents:
aa16b4a
Message:
  • Fix LDAP problem with special characters in RDN (#1486320)
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    raa16b4a r1004407  
    22=========================== 
    33 
     4- Fix LDAP problem with special characters in RDN (#1486320) 
    45- Improved handling of message parts of type message/rfc822 
    56- Updated TinyMCE to 3.2.7 
  • program/include/rcube_ldap.php

    r0102742 r1004407  
    406406    if ($this->conn && $dn) 
    407407    { 
    408       $this->_debug("C: Read [dn: ".base64_decode($dn)."] [(objectclass=*)]"); 
    409      
    410       if ($this->ldap_result = @ldap_read($this->conn, base64_decode($dn), '(objectclass=*)', array_values($this->fieldmap))) 
     408      $dn = base64_decode($dn); 
     409 
     410      $this->_debug("C: Read [dn: $dn] [(objectclass=*)]"); 
     411     
     412      if ($this->ldap_result = @ldap_read($this->conn, $dn, '(objectclass=*)', array_values($this->fieldmap))) 
    411413        $entry = ldap_first_entry($this->conn, $this->ldap_result); 
    412414      else 
     
    420422 
    421423        // Add in the dn for the entry. 
    422         $rec['dn'] = base64_decode($dn); 
     424        $rec['dn'] = $dn; 
    423425        $res = $this->_ldap2result($rec); 
    424426        $this->result = new rcube_result_set(1); 
     
    460462 
    461463    // Build the new entries DN. 
    462     $dn = $this->prop['LDAP_rdn'].'='.$newentry[$this->prop['LDAP_rdn']].','.$this->prop['base_dn']; 
     464    $dn = $this->prop['LDAP_rdn'].'='.rcube_ldap::quote_string($newentry[$this->prop['LDAP_rdn']], true) 
     465      .','.$this->prop['base_dn']; 
    463466 
    464467    $this->_debug("C: Add [dn: $dn]: ".print_r($newentry, true)); 
     
    533536      // Handle RDN change 
    534537      if ($replacedata[$this->prop['LDAP_rdn']]) { 
    535         $newdn = $this->prop['LDAP_rdn'].'='.$replacedata[$this->prop['LDAP_rdn']].','.$this->prop['base_dn'];  
     538        $newdn = $this->prop['LDAP_rdn'].'=' 
     539          .rcube_ldap::quote_string($replacedata[$this->prop['LDAP_rdn']], true) 
     540          .','.$this->prop['base_dn'];  
    536541        if ($dn != $newdn) { 
    537           $newrdn = $this->prop['LDAP_rdn'].'='.$replacedata[$this->prop['LDAP_rdn']]; 
     542          $newrdn = $this->prop['LDAP_rdn'].'=' 
     543            .rcube_ldap::quote_string($replacedata[$this->prop['LDAP_rdn']], true); 
    538544          unset($replacedata[$this->prop['LDAP_rdn']]); 
    539545        } 
     
    693699   * @static 
    694700   */ 
    695   function quote_string($str) 
    696   { 
    697     return strtr($str, array('*'=>'\2a', '('=>'\28', ')'=>'\29', '\\'=>'\5c')); 
     701  function quote_string($str, $dn=false) 
     702  { 
     703    if ($dn) 
     704      $replace = array(','=>'\2c', '='=>'\3d', '+'=>'\2b', '<'=>'\3c', 
     705        '>'=>'\3e', ';'=>'\3b', '\\'=>'\5c', '"'=>'\22', '#'=>'\23'); 
     706    else 
     707      $replace = array('*'=>'\2a', '('=>'\28', ')'=>'\29', '\\'=>'\5c', 
     708        '/'=>'\2f'); 
     709 
     710    return strtr($str, $replace); 
    698711  } 
    699712 
Note: See TracChangeset for help on using the changeset viewer.