Commit b7c750b0 authored by Sam Varshavchik's avatar Sam Varshavchik

cone: UTF8 implementation.

parent 2c68db0d
2018-07-29 Sam Varshavchik <mrsam@courier-mta.com>
* Enable UTF8 mode when sending SMTP mail. Recognize and display
UTF8 messages and delivery status notifications. Use message/global
MIME type when forwarding a UTF8 message.
2018-07-21 Sam Varshavchik <mrsam@courier-mta.com>
* Enable UTF8 mode when connecting to IMAP and POP3 servers that
......
......@@ -25,6 +25,7 @@
#include "passwordlist.H"
#include "gpglib/gpglib.h"
#include "messagesize.H"
#include "rfc2045/rfc2045.h"
#include "rfc822/rfc822.h"
#include "rfc822/rfc822hdr.h"
#include "curses/cursesscreen.H"
......@@ -104,6 +105,28 @@ void CursesMessage::SaveText::operator()(std::string text)
o.write(&*text.begin(), text.size());
}
class CursesMessage::SaveTextParseMime : public SaveText {
public:
struct rfc2045 *rfc2045p;
SaveTextParseMime(std::ostream &o)
: SaveText(o),
rfc2045p(rfc2045_alloc())
{
}
~SaveTextParseMime()
{
rfc2045_free(rfc2045p);
}
void operator()(std::string text)
{
rfc2045_parse(rfc2045p, text.c_str(), text.size());
SaveText::operator()(text);
}
};
///////////////////////////////////////////////////////////////////
......@@ -354,13 +377,16 @@ bool (CursesMessage::* CursesMessage::getHandler(mail::mimestruct &s))(size_t)
if (s.type == "TEXT")
{
if (s.subtype == "PLAIN" ||
s.subtype == "RFC822-HEADERS" ||
s.subtype == "HTML" ||
(s.subtype == "X-GPG-OUTPUT" &&
tmpaccount && usingTmpaccount))
return &CursesMessage::readTextPlain;
}
if (rfc2045_message_headers_content_type( (s.type + "/" + s.subtype)
.c_str()))
return &CursesMessage::readTextPlain;
if (reformatCompletedFunc)
// Not showing the message, downloading it for some other
// purpose
......@@ -2708,7 +2734,15 @@ void CursesMessage::forward()
std::ofstream otmpfile(tmpfile.c_str());
otmpfile << "Content-Type: message/rfc822" << std::endl
extern char should_be_same[sizeof(RFC2045_MIME_MESSAGE_RFC822)
==
sizeof(RFC2045_MIME_MESSAGE_GLOBAL)
? 1:-1];
(void)sizeof(should_be_same);
otmpfile << "Content-Type: " RFC2045_MIME_MESSAGE_RFC822
<< std::endl
<< "Content-Description: "
<< shown[n].envelope->subject << std::endl
<< std::endl;
......@@ -2717,7 +2751,7 @@ void CursesMessage::forward()
statusBar->status(_("Downloading message..."),
statusBar->INPROGRESS);
SaveText save_attachment(otmpfile);
SaveTextParseMime save_attachment(otmpfile);
if (shown[n].structure == NULL ||
shown[n].structure->getParent() == NULL)
......@@ -2735,6 +2769,14 @@ void CursesMessage::forward()
otmpfile << std::flush;
if (save_attachment.rfc2045p->rfcviolation &
RFC2045_ERR8BITHEADER)
{
otmpfile.seekp(0);
otmpfile << "Content-Type: " RFC2045_MIME_MESSAGE_GLOBAL
<< std::flush;
}
if (otmpfile.fail() ||
(otmpfile.close(), rename(tmpfile.c_str(),
attfile.c_str())) < 0)
......
......@@ -136,6 +136,8 @@ public:
virtual void operator()(std::string text);
};
class SaveTextParseMime;
// Helper class for prompting for encryption info
class EncryptionInfo {
......
/*
** Copyright 2004-2008, Double Precision Inc.
** Copyright 2004-2018, Double Precision Inc.
**
** See COPYING for distribution information.
*/
......@@ -8,6 +8,7 @@
#include "headers.H"
#include "rfc822/encode.h"
#include "rfc2045/rfc2045charset.h"
#include "rfc2045/rfc2045.h"
#include <sys/time.h>
#include "attachments.H"
#include <stdio.h>
......@@ -83,7 +84,7 @@ void mail::Attachment::check_multipart_encoding()
const char *p=multipart_type.c_str();
if (strncmp(p, "MULTIPART/", 10) == 0 ||
strcmp(p, "MESSAGE/RFC822") == 0)
rfc2045_message_content_type(p))
transfer_encoding="8bit";
}
......@@ -194,7 +195,7 @@ void mail::Attachment::add_content_encoding()
// Already have the header. Must be already encoded.
strncmp(p, "MULTIPART/", 10) == 0 ||
strcmp(p, "MESSAGE/RFC822") == 0)
rfc2045_message_content_type(p))
{
transfer_encoding="8bit";
return;
......@@ -323,7 +324,7 @@ void mail::Attachment::common_multipart_init()
mail::upper(multipart_type);
if (multipart_type == "MESSAGE/RFC822")
if (rfc2045_message_content_type(multipart_type.c_str()))
{
if (parts.size() > 1) // Woot?
{
......
......@@ -1374,6 +1374,7 @@ void mail::generic::genericMakeMimeStructure(mail::mimestruct &s,
s.content_size=end_pos - start_body;
s.content_lines=nbodylines;
s.smtputf8=rfcp->rfcviolation & RFC2045_ERR8BITHEADER ? true:false;
try {
while (h && rfc2045header_get(h, &header, &value, 0) == 0)
......
......@@ -71,7 +71,7 @@ public:
// Internal date:
before,
on,
on,
since,
// Sent date,
......
......@@ -240,7 +240,7 @@ std::string mail::mimestruct::parameterList::toString(string s) const
}
mail::mimestruct::mimestruct()
: content_size(0), content_lines(0),
: content_size(0), content_lines(0), smtputf8(false),
message_rfc822_envelope(0), parent(0)
{
}
......@@ -257,6 +257,13 @@ mail::mimestruct::mimestruct(const mail::mimestruct &cpy)
(*this)=cpy;
}
bool mail::mimestruct::messagerfc822() const
{
std::string s=type + "/" + subtype;
return rfc2045_message_content_type(s.c_str());
}
mail::mimestruct &mail::mimestruct::operator=(const mail::mimestruct &cpy)
{
destroy();
......
......@@ -88,10 +88,7 @@ public:
std::string type, subtype; // text, plain
bool messagerfc822() const
{
return type == "MESSAGE" && subtype == "RFC822";
}
bool messagerfc822() const;
bool multipartsigned() const
{
......@@ -121,6 +118,9 @@ public:
parameterList content_disposition_parameters;
bool smtputf8;
/* 8 bit headers exist, set only when parsing a message from a file. */
mimestruct();
~mimestruct();
......
2018-07-29 Sam Varshavchik <mrsam@courier-mta.com>
* mailbot: generate message/global, message/global-delivery-status,
and message/global-headers, when needed, when formatting autoreplies.
* reformime: -m option uses message/global instead of message/rfc822
for UTF8 messages.
* sqwebmail: recognize message/global and message/rfc822 attachments.
Update very old login error message that references a long gone-by
era.
2018-07-28 Sam Varshavchik <mrsam@courier-mta.com>
* courier: implement the SMTPUTF8 extension.
......
2018-07-29 Sam Varshavchik <mrsam@courier-mta.com>
* mailbot: generate message/global, message/global-delivery-status,
and message/global-headers, when needed, when formatting autoreplies.
* reformime: -m option uses message/global instead of message/rfc822
for UTF8 messages.
2018-06-25 Sam Varshavchik <mrsam@courier-mta.com>
* rfc2045/reformime.c (main2): fix crash if -x or -X is specified
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment