[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepimlibs/kimap
From: Kevin Ottens <ervin () kde ! org>
Date: 2009-04-05 15:37:18
Message-ID: 1238945838.814072.3486.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 949627 by ervin:
Merge some of the changes from the akonadiserver copy of the imap stream
parser. Also add a workaround when reading list, we apparently sometimes
get extra CRLF after literals, in such a case we've to skip them.
Otherwise any further read string attempt will fail, potentially
creating an infinite loop.
M +17 -30 imapstreamparser.cpp
--- trunk/KDE/kdepimlibs/kimap/imapstreamparser.cpp #949626:949627
@@ -53,39 +53,14 @@
throw ImapParserException("Unable to read more data");
stripLeadingSpaces();
if ( !waitForMoreData( m_position >= m_data.length() ) )
- throw ImapParserException("Unable to read more data");;
+ throw ImapParserException("Unable to read more data");
// literal string
// TODO: error handling
- if ( m_data[m_position] == '{' ) {
- int end = -1;
- do {
- end = m_data.indexOf( '}', m_position );
- if ( !waitForMoreData( end == -1 ) )
- throw ImapParserException("Unable to read more data");
- } while (end == -1);
- Q_ASSERT( end > m_position );
- int size = m_data.mid( m_position + 1, end - m_position - 1 ).toInt();
-
- // strip CRLF
- m_position = end + 1;
-
- if ( m_position < m_data.length() && m_data[m_position] == '\r' )
- ++m_position;
- if ( m_position < m_data.length() && m_data[m_position] == '\n' )
- ++m_position;
-
-
- end = m_position + size;
- //FIXME: Makes sense only on the server side?
- //m_continuationSize = end - m_data.length();
- //if (m_continuationSize > 0)
- // sendContinuationResponse();
- if ( !waitForMoreData( m_data.length() < end ) )
- throw ImapParserException("Unable to read more data");
-
- result = m_data.mid( m_position, end - m_position );
- m_position = end;
+ if ( hasLiteral() ) {
+ while (!atLiteralEnd()) {
+ result += readLiteralPart();
+ }
return result;
}
@@ -175,6 +150,9 @@
m_position += size;
m_literalSize -= size;
Q_ASSERT(m_literalSize >= 0);
+ m_data = m_data.right( m_data.size() - m_position );
+ m_position = 0;
+
return result;
}
@@ -275,6 +253,13 @@
} else {
ba = readString();
}
+
+ // We might sometime get some unwanted CRLF, but we're still not at the end
+ // of the list, would make further string reads fail so eat the CRLFs.
+ while ( m_data[m_position]=='\r' || m_data[m_position]=='\n' ) {
+ m_position++;
+ }
+
i = m_position - 1;
if (concatToLast) {
result.last()+=ba;
@@ -474,6 +459,7 @@
{
if ( !waitForMoreData( m_position >= m_data.length() ) )
throw ImapParserException("Unable to read more data");
+ int savedPos = m_position;
stripLeadingSpaces();
if ( m_data[m_position] == '\n' || m_data[m_position] == '\r') {
if ( m_position < m_data.length() && m_data[m_position] == '\r' )
@@ -487,6 +473,7 @@
return true; //command end
}
+ m_position = savedPos;
return false; //something else
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic