From 56f5f0dce7f17a1464d593c18ed092543569aab1 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Mon, 20 Feb 2006 18:00:15 +0000 Subject: [PATCH] Accept 8-bit characters even if not allowed (non-strict mode). --- ChangeLog | 6 ++++++ vmime/net/imap/IMAPParser.hpp | 29 ++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e8b4c35b..29bdf09b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,12 @@ VERSION 0.8.1cvs ================ +2006-02-20 Vincent Richard + + * net/imap/IMAPParser.hpp: added a "relaxed" mode to allow 8-bit + characters where not allowed by the standard (thanks to Tim Teulings + for having found the bug). + 2006-01-29 Vincent Richard * Added service::isSecuredConnection() and service::getConnectionInfos() diff --git a/vmime/net/imap/IMAPParser.hpp b/vmime/net/imap/IMAPParser.hpp index 88d751af..ac6310b2 100644 --- a/vmime/net/imap/IMAPParser.hpp +++ b/vmime/net/imap/IMAPParser.hpp @@ -134,7 +134,7 @@ class IMAPParser : public object public: IMAPParser(weak_ref tag, weak_ref sok, weak_ref _timeoutHandler) - : m_tag(tag), m_socket(sok), m_progress(NULL), + : m_tag(tag), m_socket(sok), m_progress(NULL), m_strict(false), m_literalHandler(NULL), m_timeoutHandler(_timeoutHandler) { } @@ -150,6 +150,27 @@ public: m_socket = sok; } + /** Set whether we operate in strict mode (this may not work + * with some servers which are not fully standard-compliant). + * + * @param strict true to operate in strict mode, or false + * to operate in default, relaxed mode + */ + void setStrict(const bool strict) + { + m_strict = strict; + } + + /** Return true if the parser operates in strict mode, or + * false otherwise. + * + * @return true if we are in strict mode, false otherwise + */ + const bool isStrict() const + { + return m_strict; + } + const string lastLine() const { @@ -562,14 +583,14 @@ public: { } - void go(IMAPParser& /* parser */, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("text"); string::size_type pos = *currentPos; string::size_type len = 0; - if (m_allow8bits) + if (m_allow8bits || !parser.isStrict()) { const unsigned char except = m_except; @@ -5000,6 +5021,8 @@ private: utility::progressListener* m_progress; + bool m_strict; + literalHandler* m_literalHandler; weak_ref m_timeoutHandler;