aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2013-12-11 21:53:39 +0000
committerVincent Richard <[email protected]>2013-12-11 21:53:39 +0000
commit5f63d4740192d617bd45ad8ff3d336f44461b18a (patch)
treee8d3fbfebc7c799552d0d435b812d8e48fcb84be
parentAllow overriding auto-detection of shared_ptr<> implementation. (diff)
downloadvmime-5f63d4740192d617bd45ad8ff3d336f44461b18a.tar.gz
vmime-5f63d4740192d617bd45ad8ff3d336f44461b18a.zip
IMAP parsing workarounds for Yandex.
-rw-r--r--vmime/net/imap/IMAPParser.hpp35
1 files changed, 32 insertions, 3 deletions
diff --git a/vmime/net/imap/IMAPParser.hpp b/vmime/net/imap/IMAPParser.hpp
index 0b90829e..8c7fcb60 100644
--- a/vmime/net/imap/IMAPParser.hpp
+++ b/vmime/net/imap/IMAPParser.hpp
@@ -975,6 +975,7 @@ public:
public:
const string& value() const { return (m_value); }
+ void setValue(const string& val) { m_value = val; }
};
@@ -2940,7 +2941,23 @@ public:
size_t pos = *currentPos;
- m_string1 = parser.get <xstring>(line, &pos);
+ if (!parser.isStrict())
+ {
+ // Some servers send an <atom> instead of a <string> here:
+ // eg. ... (CHARSET "X-UNKNOWN") ...
+ if (!(m_string1 = parser.get <xstring>(line, &pos, true)))
+ {
+ std::auto_ptr <atom> at(parser.get <atom>(line, &pos));
+
+ m_string1 = new xstring();
+ m_string1->setValue(at->value());
+ }
+ }
+ else
+ {
+ m_string1 = parser.get <xstring>(line, &pos);
+ }
+
parser.check <SPACE>(line, &pos);
m_string2 = parser.get <xstring>(line, &pos);
@@ -4453,9 +4470,21 @@ public:
size_t pos = *currentPos;
parser.check <one_char <'+'> >(line, &pos);
- parser.check <SPACE>(line, &pos);
- m_resp_text = parser.get <IMAPParser::resp_text>(line, &pos);
+ if (!parser.isStrict())
+ {
+ // Some servers do not send SPACE when response text is empty
+ if (parser.check <SPACE>(line, &pos, true))
+ m_resp_text = parser.get <IMAPParser::resp_text>(line, &pos);
+ else
+ m_resp_text = new IMAPParser::resp_text(); // empty
+ }
+ else
+ {
+ parser.check <SPACE>(line, &pos);
+
+ m_resp_text = parser.get <IMAPParser::resp_text>(line, &pos);
+ }
parser.check <CRLF>(line, &pos);