Changeset 274

Show
Ignore:
Timestamp:
08/19/08 07:51:07 PM (3 months ago)
Author:
octorian
Message:

Fixes for #96

Location:
branches/LogicMail-1.0/LogicMail/src/org/logicprobe/LogicMail
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/LogicMail-1.0/LogicMail/src/org/logicprobe/LogicMail/mail/imap/ImapParser.java

    r198 r274  
    213213                    hostName = (String)entry.elementAt(3); 
    214214                } 
     215                 
     216                String addrStr = 
     217                        (mbName.equals(strNIL) ? "" : mbName) + 
     218                        (hostName.equals(strNIL) ? "" : ('@' + hostName)); 
    215219                // Now assemble these into a single address entry 
    216220                // (possibly eventually storing them separately) 
    217221                if(realName.length() > 0 && !realName.equals(strNIL)) { 
    218                     addrList[index] = realName + " <" + mbName + "@" + hostName + ">"; 
     222                    addrList[index] = realName + " <" + addrStr + ">"; 
    219223                } 
    220224                else { 
    221                     addrList[index] = mbName + "@" + hostName; 
     225                    addrList[index] = addrStr; 
    222226                } 
    223227                index++; 
  • branches/LogicMail-1.0/LogicMail/src/org/logicprobe/LogicMail/ui/CompositionScreen.java

    r200 r274  
    128128        if(env.to != null) { 
    129129            for(i=0; i<env.to.length; i++) { 
    130                 insertRecipientField(EmailAddressBookEditField.ADDRESS_TO).setAddress(env.to[i]); 
     130                if(env.to[i].indexOf('@') != -1) { 
     131                    insertRecipientField(EmailAddressBookEditField.ADDRESS_TO).setAddress(env.to[i]); 
     132                } 
    131133            } 
    132134        } 
    133135        if(env.cc != null) { 
    134136            for(i=0; i<env.cc.length; i++) { 
    135                 insertRecipientField(EmailAddressBookEditField.ADDRESS_CC).setAddress(env.cc[i]); 
     137                if(env.cc[i].indexOf('@') != -1) { 
     138                    insertRecipientField(EmailAddressBookEditField.ADDRESS_CC).setAddress(env.cc[i]); 
     139                } 
    136140            } 
    137141        } 
    138142        if(env.bcc != null) { 
    139143            for(i=0; i<env.bcc.length; i++) { 
    140                 insertRecipientField(EmailAddressBookEditField.ADDRESS_BCC).setAddress(env.bcc[i]); 
     144                if(env.bcc[i].indexOf('@') != -1) { 
     145                    insertRecipientField(EmailAddressBookEditField.ADDRESS_BCC).setAddress(env.bcc[i]); 
     146                } 
    141147            } 
    142148        } 
  • branches/LogicMail-1.0/LogicMail/src/org/logicprobe/LogicMail/util/StringParser.java

    r254 r274  
    334334        return buf.toString(); 
    335335    } 
    336      
     336 
    337337    /** 
    338338     * Recursively parse a nested paren string. 
     
    359359        boolean inQuote = false; 
    360360        while(q < rawText.length()) { 
    361             if(rawText.charAt(q) == '\"') { 
     361            if(isQuoteChar(rawText, q, p)) { 
    362362                if(!inQuote) { 
    363363                    inQuote = true; 
     
    422422                        } 
    423423                    } 
    424                     if(rawText.charAt(i) == '\"' && !subInQuote) { 
     424 
     425                    if(isQuoteChar(rawText, i, q+1) && !subInQuote) { 
    425426                        subInQuote = true; 
    426427                    } 
    427                     else if(rawText.charAt(i) == '\"' && subInQuote) { 
     428                    else if(isQuoteChar(rawText, i, q+1) && subInQuote) { 
    428429                        subInQuote = false; 
    429430                    } 
     
    454455        } 
    455456        return parsedText; 
     457    } 
     458 
     459    /** 
     460     * Helper method to determine if a character is a quote. 
     461     */ 
     462    private static boolean isQuoteChar(String rawText, int index, int startIndex) 
     463    { 
     464        if(index == startIndex) { 
     465            return rawText.charAt(index) == '\"'; 
     466        } 
     467        else if(rawText.charAt(index) == '\"') { 
     468            if(rawText.charAt(index - 1) == '\\') { 
     469                if(index - 2 < startIndex || rawText.charAt(index - 2) == '\\') { 
     470                    return true; 
     471                } 
     472                else { 
     473                    return false; 
     474                } 
     475            } 
     476            else { 
     477                return true; 
     478            } 
     479        } 
     480        else { 
     481            return false; 
     482        } 
    456483    } 
    457484