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

Fixes for #96

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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