Show
Ignore:
Timestamp:
07/04/08 14:36:58 (5 months ago)
Author:
cyrusdaboo
Message:

Parse out the user:password portion of http URLs. This will allow us to set user ids in
web calendar URLs to allow keychain based logins to work properly.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Mulberry/branches/v4.1d1/Sources_Common/Mail/URLs/CURL.cp

    r86 r167  
    209209                // Look for server 
    210210                const char* p = ::strchr(temp.c_str(), '/'); 
     211                cdstring host; 
    211212                if (p == NULL) 
    212                         mServer = temp; 
     213                { 
     214                        host = temp; 
     215                } 
    213216                else 
    214217                { 
     
    216219                        if (punt_size != 0) 
    217220                        { 
    218                                 mServer.assign(temp, 0, punt_size); 
     221                                host.assign(temp, 0, punt_size); 
    219222                                temp.erase(0, punt_size); 
    220223                        } 
     
    224227                                mPath.DecodeURL(); 
    225228                } 
     229                 
     230                // Now decode user:password@server 
     231                p = ::strchr(host.c_str(), '@'); 
     232                cdstring userpswd; 
     233                if (p == NULL) 
     234                { 
     235                        mServer = host; 
     236                } 
     237                else 
     238                { 
     239                        punt_size = p - host.c_str(); 
     240                        if (punt_size != 0) 
     241                        { 
     242                                userpswd.assign(host, 0, punt_size); 
     243                                host.erase(0, punt_size+1); 
     244                        } 
     245                        mServer = host; 
     246                         
     247                        p = ::strchr(userpswd.c_str(), ':'); 
     248                        if (p == NULL) 
     249                        { 
     250                                mUser = userpswd; 
     251                        } 
     252                        else 
     253                        { 
     254                                punt_size = p - userpswd.c_str(); 
     255                                if (punt_size != 0) 
     256                                { 
     257                                        mUser.assign(userpswd, 0, punt_size); 
     258                                        userpswd.erase(0, punt_size+1); 
     259                                } 
     260                                 
     261                                mPassword = userpswd; 
     262                        } 
     263                } 
    226264                break; 
    227265        } 
     
    251289        { 
    252290                result += mScheme; 
     291                switch(mSchemeType) 
     292                { 
     293                case eHTTP: 
     294                case eHTTPS: 
     295                case eWebcal: 
     296                { 
     297                        if (!mUser.empty()) 
     298                        { 
     299                                result += mUser; 
     300                                if (!mPassword.empty()) 
     301                                { 
     302                                        result += ":"; 
     303                                        result += mPassword; 
     304                                } 
     305                                result += "@"; 
     306                        } 
     307                } 
     308                default:; 
     309                } 
    253310                result += mServer; 
    254311        } 
     
    276333        // Compare each component 
    277334        if (mScheme.compare(comp.mScheme, true) != 0) 
     335                return false; 
     336         
     337        if (mUser.compare(comp.mUser, true) != 0) 
     338                return false; 
     339         
     340        if (mPassword.compare(comp.mPassword, true) != 0) 
    278341                return false; 
    279342