message-part-data.c revision bc41d811809ca144922697333b78a857b97546c9
/* Copyright (c) 2014-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "wildcard-match.h"
#include "array.h"
#include "rfc822-parser.h"
#include "rfc2231-parser.h"
#include "message-address.h"
#include "message-header-parser.h"
#include "message-part-data.h"
const char *message_part_envelope_headers[] = {
"Date", "Subject", "From", "Sender", "Reply-To",
"To", "Cc", "Bcc", "In-Reply-To", "Message-ID",
};
/*
*
*/
{
multipart stuff */
return FALSE;
return FALSE; /* shouldn't happen normally.. */
return FALSE;
/* only allowed parameter is charset=us-ascii, which is also default */
if (data->content_type_params_count == 0) {
/* charset defaults to us-ascii */
MESSAGE_PART_DEFAULT_CHARSET) != 0)
return FALSE;
return FALSE;
return FALSE;
/* BODYSTRUCTURE checks: */
return FALSE;
return TRUE;
}
const char **filename_r)
{
const struct message_part_param *params;
unsigned int params_count, i;
return FALSE;
}
for (i = 0; i < params_count; i++) {
return TRUE;
}
}
return FALSE;
}
/*
* Header parsing
*/
/* Message part envelope */
enum envelope_field {
ENVELOPE_FIELD_DATE = 0,
};
static enum envelope_field
envelope_get_field(const char *name)
{
switch (*name) {
case 'B':
case 'b':
return ENVELOPE_FIELD_BCC;
break;
case 'C':
case 'c':
return ENVELOPE_FIELD_CC;
break;
case 'D':
case 'd':
return ENVELOPE_FIELD_DATE;
break;
case 'F':
case 'f':
return ENVELOPE_FIELD_FROM;
break;
case 'I':
case 'i':
return ENVELOPE_FIELD_IN_REPLY_TO;
break;
case 'M':
case 'm':
return ENVELOPE_FIELD_MESSAGE_ID;
break;
case 'R':
case 'r':
return ENVELOPE_FIELD_REPLY_TO;
break;
case 'S':
case 's':
return ENVELOPE_FIELD_SUBJECT;
return ENVELOPE_FIELD_SENDER;
break;
case 'T':
case 't':
return ENVELOPE_FIELD_TO;
break;
}
return ENVELOPE_FIELD_UNKNOWN;
}
struct message_part_envelope **data,
struct message_header_line *hdr)
{
struct message_part_envelope *d;
enum envelope_field field;
struct message_address **addr_p;
const char **str_p;
}
return;
if (field == ENVELOPE_FIELD_UNKNOWN)
return;
/* wait for full value */
return;
}
d = *data;
switch (field) {
case ENVELOPE_FIELD_DATE:
break;
case ENVELOPE_FIELD_SUBJECT:
break;
str_p = &d->message_id;
break;
str_p = &d->in_reply_to;
break;
case ENVELOPE_FIELD_CC:
break;
case ENVELOPE_FIELD_BCC:
break;
case ENVELOPE_FIELD_FROM:
break;
case ENVELOPE_FIELD_SENDER:
break;
case ENVELOPE_FIELD_TO:
break;
case ENVELOPE_FIELD_REPLY_TO:
break;
case ENVELOPE_FIELD_UNKNOWN:
i_unreached();
}
}
}
/* Message part data */
static void
unsigned int *params_count_r)
{
const char *const *results;
struct message_part_param *params;
unsigned int params_count, i;
params_count /= 2;
if (params_count > 0) {
for (i = 0; i < params_count; i++) {
}
}
}
static void
{
struct rfc822_parser_context parser;
const char *value;
unsigned int i;
int ret;
/* Save content type and subtype */
for (i = 0; value[i] != '\0'; i++) {
if (value[i] == '/') {
break;
}
}
str_truncate(str, i);
if (ret < 0) {
/* Content-Type is broken, but we wanted to get it as well as
we could. Don't try to read the parameters anymore though.
We don't completely ignore a broken Content-Type, because
mismatch with the message_part's MESSAGE_PART_FLAG_TEXT. */
return;
}
}
static void
{
struct rfc822_parser_context parser;
}
}
static void
{
struct rfc822_parser_context parser;
return;
}
static void
{
struct rfc822_parser_context parser;
/* Language-Header = "Content-Language" ":" 1#Language-tag
Language-Tag = Primary-tag *( "-" Subtag )
Primary-tag = 1*8ALPHA
Subtag = 1*8ALPHA */
str_truncate(str, 0);
break;
}
if (array_count(&langs) > 0) {
}
}
static void
{
const char *value;
return;
}
switch (*name) {
case 'i':
case 'I':
break;
case 'm':
case 'M':
break;
case 't':
case 'T':
break;
case 'l':
case 'L':
}
break;
case 'd':
case 'D':
break;
}
}
struct message_part *part,
struct message_header_line *hdr)
{
struct message_part_data *part_data;
struct message_part_envelope *envelope;
bool parent_rfc822;
/* no Content-* headers. add an empty context
structure anyway. */
/* If there was no Mime-Version, forget all
the Content-stuff */
}
return;
}
return;
return;
/* initialize message part data */
}
T_BEGIN {
} T_END;
}
if (parent_rfc822) {
}
}
const char *const *types)
{
const char *const *ptr;
const char *content_type;
return FALSE;
else
}
return ret;
}
bool has_value)
{
for (unsigned int i = 0; i < data->content_disposition_params_count; i++) {
const struct message_part_param *param =
return TRUE;
}
}
return FALSE;
}
const struct message_part_attachment_settings *set)
{
/* see if the content-type is excluded */
return FALSE;
/* accept any attachment, or any inlined attachment with filename,
unless inlined ones are excluded */
(!set->exclude_inlined &&
return TRUE;
return FALSE;
}