1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-24 02:12:15 -05:00

Quoted strings can contain '"' in escaped form. readStringUntil() fails to unescape and will will return prematurely when the string contains an escaped '"' character.

Fixes issue 512.
This commit is contained in:
cketti 2010-04-30 13:51:19 +00:00
parent 732b282ddc
commit c6fee3efb9

View File

@ -317,7 +317,28 @@ public class ImapResponseParser
private String parseQuoted() throws IOException
{
expect('"');
return readStringUntil('"');
StringBuffer sb = new StringBuffer();
int ch;
boolean escape = false;
while ((ch = mIn.read()) != -1)
{
if (!escape && (ch == '\\'))
{
// Found the escape character
escape = true;
}
else if (!escape && (ch == '"'))
{
return sb.toString();
}
else
{
sb.append((char)ch);
escape = false;
}
}
throw new IOException("parseQuoted(): end of stream reached");
}
private String readStringUntil(char end) throws IOException
@ -335,7 +356,7 @@ public class ImapResponseParser
sb.append((char)ch);
}
}
throw new IOException("readQuotedString(): end of stream reached");
throw new IOException("readStringUntil(): end of stream reached");
}
private int expect(char ch) throws IOException