Miscellaneous email parsing routines. More...
#include "config.h"
#include <ctype.h>
#include <string.h>
#include <time.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "mutt.h"
#include "parse.h"
#include "body.h"
#include "email.h"
#include "envelope.h"
#include "from.h"
#include "globals.h"
#include "mime.h"
#include "parameter.h"
#include "rfc2047.h"
#include "rfc2231.h"
#include "url.h"
#include "autocrypt/lib.h"
Go to the source code of this file.
Macros | |
#define | CONTENT_TOO_BIG (1 << 30) |
Functions | |
static void | parse_part (FILE *fp, struct Body *b, int *counter) |
Parse a MIME part. More... | |
static struct Body * | rfc822_parse_message (FILE *fp, struct Body *parent, int *counter) |
Parse a Message/RFC822 body. More... | |
static struct Body * | parse_multipart (FILE *fp, const char *boundary, LOFF_T end_off, bool digest, int *counter) |
Parse a multipart structure. More... | |
void | mutt_auto_subscribe (const char *mailto) |
Check if user is subscribed to mailing list. More... | |
static void | parse_parameters (struct ParameterList *pl, const char *s, bool allow_value_spaces) |
Parse a list of Parameters. More... | |
static void | parse_content_disposition (const char *s, struct Body *ct) |
Parse a content disposition. More... | |
static void | parse_references (struct ListHead *head, const char *s) |
Parse references from an email header. More... | |
static void | parse_content_language (const char *s, struct Body *ct) |
Read the content's language. More... | |
bool | mutt_matches_ignore (const char *s) |
Does the string match the ignore list. More... | |
enum ContentType | mutt_check_mime_type (const char *s) |
Check a MIME type string. More... | |
char * | mutt_extract_message_id (const char *s, size_t *len) |
Find a message-id. More... | |
int | mutt_check_encoding (const char *c) |
Check the encoding type. More... | |
void | mutt_parse_content_type (const char *s, struct Body *ct) |
Parse a content type. More... | |
static struct AutocryptHeader * | parse_autocrypt (struct AutocryptHeader *head, const char *s) |
Parse an Autocrypt header line. More... | |
static char * | rfc2369_first_mailto (const char *body) |
Extract the first mailto: URL from a RFC2369 list. More... | |
int | mutt_rfc822_parse_line (struct Envelope *env, struct Email *e, const char *name, const char *body, bool user_hdrs, bool weed, bool do_2047) |
Parse an email header. More... | |
char * | mutt_rfc822_read_line (FILE *fp, char *line, size_t *linelen) |
Read a header line from a file. More... | |
struct Envelope * | mutt_rfc822_read_header (FILE *fp, struct Email *e, bool user_hdrs, bool weed) |
Parses an RFC822 header. More... | |
struct Body * | mutt_read_mime_header (FILE *fp, bool digest) |
Parse a MIME header. More... | |
bool | mutt_is_message_type (int type, const char *subtype) |
Determine if a mime type matches a message or not. More... | |
bool | mutt_parse_mailto (struct Envelope *env, char **body, const char *src) |
Parse a mailto:// url. More... | |
void | mutt_parse_part (FILE *fp, struct Body *b) |
Parse a MIME part. More... | |
struct Body * | mutt_rfc822_parse_message (FILE *fp, struct Body *parent) |
Parse a Message/RFC822 body. More... | |
struct Body * | mutt_parse_multipart (FILE *fp, const char *boundary, LOFF_T end_off, bool digest) |
Parse a multipart structure. More... | |
Miscellaneous email parsing routines.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file parse.c.
|
static |
Parse a MIME part.
fp | File to read from |
b | Body to store the results in |
counter | Number of parts processed so far |
Definition at line 1458 of file parse.c.
Parse a Message/RFC822 body.
fp | Stream to read from |
parent | Info about the message/rfc822 body part |
counter | Number of parts processed so far |
ptr | New Body containing parsed message |
Definition at line 1640 of file parse.c.
|
static |
Parse a multipart structure.
fp | Stream to read from |
boundary | Body separator |
end_off | Length of the multipart body (used when the final boundary is missing to avoid reading too far) |
digest | true if reading a multipart/digest |
counter | Number of parts processed so far |
ptr | New Body containing parsed structure |
Definition at line 1531 of file parse.c.
void mutt_auto_subscribe | ( | const char * | mailto | ) |
Check if user is subscribed to mailing list.
mailto | URL of mailing list subscribe |
Definition at line 67 of file parse.c.
|
static |
Parse a list of Parameters.
pl | Parameter list for the results |
s | String to parse |
allow_value_spaces | Allow values with spaces |
Autocrypt defines an irregular parameter format that doesn't follow the rfc. It splits keydata across multiple lines without parameter continuations. The allow_value_spaces parameter allows parsing those values which are split by spaces when unfolded.
Definition at line 110 of file parse.c.
|
static |
Parse a content disposition.
s | String to parse |
ct | Body to save the result |
e.g. parse a string "inline" and set DISP_INLINE.
Definition at line 248 of file parse.c.
|
static |
Parse references from an email header.
head | List to receive the references |
s | String to parse |
Definition at line 280 of file parse.c.
|
static |
bool mutt_matches_ignore | ( | const char * | s | ) |
Does the string match the ignore list.
s | String to check |
true | String matches |
Checks Ignore and UnIgnore using mutt_list_match
Definition at line 313 of file parse.c.
enum ContentType mutt_check_mime_type | ( | const char * | s | ) |
char* mutt_extract_message_id | ( | const char * | s, |
size_t * | len | ||
) |
Find a message-id.
[in] | s | String to parse |
[out] | len | Number of bytes of s parsed |
ptr | Message id found |
NULL | No more message ids |
Definition at line 360 of file parse.c.
int mutt_check_encoding | ( | const char * | c | ) |
Check the encoding type.
c | String to check |
num | Encoding type, e.g. ENC_QUOTED_PRINTABLE |
Definition at line 396 of file parse.c.
void mutt_parse_content_type | ( | const char * | s, |
struct Body * | ct | ||
) |
Parse a content type.
s | String to parse |
ct | Body to save the result |
e.g. parse a string "inline" and set DISP_INLINE.
Definition at line 424 of file parse.c.
|
static |
Parse an Autocrypt header line.
head | Autocrypt header to insert before |
s | Header string to parse |
ptr | New AutocryptHeader inserted before head |
Definition at line 529 of file parse.c.
|
static |
Extract the first mailto: URL from a RFC2369 list.
body | Body of the header |
ptr | First mailto: URL found, or NULL if none was found |
Definition at line 593 of file parse.c.
int mutt_rfc822_parse_line | ( | struct Envelope * | env, |
struct Email * | e, | ||
const char * | name, | ||
const char * | body, | ||
bool | user_hdrs, | ||
bool | weed, | ||
bool | do_2047 | ||
) |
Parse an email header.
env | Envelope of the email |
e | |
name | Header field name, e.g. 'to' |
body | Header field body, e.g. 'john@' exam ple.c om |
user_hdrs | If true, save into the Envelope's userhdrs |
weed | If true, perform header weeding (filtering) |
do_2047 | If true, perform RFC2047 decoding of the field |
1 | The field is recognised |
0 | The field is not recognised |
Process a line from an email header. Each line that is recognised is parsed and the information put in the Envelope or Header.
Definition at line 634 of file parse.c.
char* mutt_rfc822_read_line | ( | FILE * | fp, |
char * | line, | ||
size_t * | linelen | ||
) |
Read a header line from a file.
fp | File to read from |
line | Buffer to store the result |
linelen | Length of buffer |
ptr | Line read from file |
Reads an arbitrarily long header field, and looks ahead for continuation lines. "line" must point to a dynamically allocated string; it is increased if more space is required to fit the whole line.
Definition at line 1083 of file parse.c.
Parses an RFC822 header.
fp | Stream to read from |
e | Current Email (optional) |
user_hdrs | If set, store user headers Used for recall-message and postpone modes |
weed | If this parameter is set and the user has activated the $weed option, honor the header weed list for user headers. Used for recall-message |
ptr | Newly allocated envelope structure |
Caller should free the Envelope using mutt_env_free().
Definition at line 1158 of file parse.c.
struct Body* mutt_read_mime_header | ( | FILE * | fp, |
bool | digest | ||
) |
bool mutt_is_message_type | ( | int | type, |
const char * | subtype | ||
) |
bool mutt_parse_mailto | ( | struct Envelope * | env, |
char ** | body, | ||
const char * | src | ||
) |
Parse a mailto:// url.
true | Success |
false | Error |
Definition at line 1671 of file parse.c.
void mutt_parse_part | ( | FILE * | fp, |
struct Body * | b | ||
) |
Parse a Message/RFC822 body.
fp | Stream to read from |
parent | Info about the message/rfc822 body part |
ptr | New Body containing parsed message |
Definition at line 1752 of file parse.c.
struct Body* mutt_parse_multipart | ( | FILE * | fp, |
const char * | boundary, | ||
LOFF_T | end_off, | ||
bool | digest | ||
) |
Parse a multipart structure.
fp | Stream to read from |
boundary | Body separator |
end_off | Length of the multipart body (used when the final boundary is missing to avoid reading too far) |
digest | true if reading a multipart/digest |
ptr | New Body containing parsed structure |
Definition at line 1768 of file parse.c.