Changeset 279

Show
Ignore:
Timestamp:
08/28/08 07:07:55 PM (4 months ago)
Author:
octorian
Message:

Merge of fixes

Location:
trunk/LogicMail/src/org/logicprobe/LogicMail
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/LogicMail/src/org/logicprobe/LogicMail/mail/imap/ImapParser.java

    r275 r279  
    283283        } 
    284284 
     285        // Find the BODYSTRUCTURE portion of the reply 
     286        Vector parsedStruct = null; 
     287        int size = parsedText.size(); 
     288 
     289        for (int i = 0; i < size; i++) { 
     290            if (parsedText.elementAt(i) instanceof String) { 
     291                String label = (String) parsedText.elementAt(i); 
     292 
     293                if (label.equalsIgnoreCase("BODYSTRUCTURE") && 
     294                        (i < (size - 1)) && 
     295                        parsedText.elementAt(i + 1) instanceof Vector) { 
     296                    parsedStruct = (Vector) parsedText.elementAt(i + 1); 
     297                } 
     298            } 
     299        } 
     300 
    285301        // Sanity checking 
    286         if ((parsedText.size() < 2) || 
    287                 !(parsedText.elementAt(1) instanceof Vector)) { 
     302        if (parsedStruct == null) { 
    288303            EventLogger.logEvent(AppInfo.GUID, 
    289304                "ImapParser.parseMessageStructure: Sanity check failed".getBytes(), 
     
    293308        } 
    294309 
    295         Vector parsedStruct = (Vector) parsedText.elementAt(1); 
    296310        MessageSection msgStructure = parseMessageStructureHelper(null, 1, 
    297311                parsedStruct); 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/util/StringParser.java

    r275 r279  
    879879                if ((index + 2) >= length) { 
    880880                    break; 
    881                 } 
    882  
    883                 try { 
    884                     int charVal = Integer.parseInt(text.substring(index + 1, 
    885                                 index + 3), 16); 
    886                     buffer.append((char) charVal); 
    887                 } catch (NumberFormatException exp) { 
    888                 } 
    889  
    890                 index += 3; 
     881                } else { 
     882                    char ch1 = text.charAt(index + 1); 
     883                    char ch2 = text.charAt(index + 2); 
     884 
     885                    if ((ch1 == '\r') && (ch2 == '\n')) { 
     886                        index += 3; 
     887                    } else if (ch1 == '\n') { 
     888                        index += 2; 
     889                    } else { 
     890                        try { 
     891                            int charVal = Integer.parseInt(text.substring(index + 
     892                                        1, index + 3), 16); 
     893                            buffer.append((char) charVal); 
     894                        } catch (NumberFormatException exp) { 
     895                        } 
     896 
     897                        index += 3; 
     898                    } 
     899                } 
    891900            } else { 
    892901                buffer.append(text.charAt(index)); 
     
    905914        char ch; 
    906915        String charStr; 
    907  
    908         for (int i = 0; i < text.length(); i++) { 
     916        int length = text.length(); 
     917 
     918        for (int i = 0; i < length; i++) { 
    909919            ch = text.charAt(i); 
    910920 
    911             if (ch < 128) { 
     921            if ((ch != '\t') && (ch != ' ') && (ch < 128)) { 
     922                if ((buffer.length() == 75) && (i < (length - 1))) { 
     923                    buffer.append("=\r\n"); 
     924                } 
     925 
    912926                buffer.append(ch); 
    913927            } else { 
    914                 charStr = Integer.toHexString((int) ch); 
     928                if ((buffer.length() == 73) && (i < (length - 3))) { 
     929                    buffer.append("=\r\n"); 
     930                } 
     931 
     932                charStr = Integer.toHexString((int) ch).toUpperCase(); 
    915933                buffer.append('='); 
    916934