View Source Pop3mail.Multipart (pop3mail v1.5.0)

Parser for: RFC 2045 Multipart content type (previously RFC 1341).

It works recursive because a multipart content can contain other multiparts. The returned sequential list of Pop3mail.Path structs is flattened. The Part.path field shows where it is in the hierarchy. This module can also be useful to parse RFC 7578 multipart/form-data (previously RFC 2388).

Summary

Functions

Return decoded text as binary.

Return decoded text as binary.

Return decoded lines as binary.

Extract (file-)name from Content-Disposition value or Content-Type value. Returns Pop3mail.Part with filled-in filename and filename_charset.

Get parameter number of key_value. key_value - format must be: key=value or key<parameter number>=value or key*=value. Returns string. Can be empty.

Get value of key_value. key_value - format must be: key=value or key<number>=value or key*=value.

Is this part a multipart? Looks if the media_type starts with multipart/.

A multipart header line can continue on the next line. When next line starts with a tab-character or when there is a opening double quote not closed yet.

Parse multipart content. Returns a flattened list of Pop3mail.Part's

Parse multipart Content-Type header line. It can contain media_type, charset, (file-)name and boundary. Returns a Pop3mail.Part

Parse value of content-type header line. It can contain media_type, charset, (file-)name and boundary. Returns a Pop3mail.Part

Parse multipart Content-Disposition header line. This is either inline or attachment, and it can contain a filename. Returns a Pop3mail.Part

Parse value of Content-Disposition header line. This is either inline or attachment, and it can contain a filename. Returns a Pop3mail.Part

Parse the boundary in the multipart content.

Parse a part of the multipart content.

Parse multipart Content-ID header line. Returns a Pop3mail.Part

Parse multipart Content-Location header line as defined in RFC 2557. Returns a Pop3mail.Part

Parse multipart Content-Type header line. It can contain media_type, charset, (file-)name and boundary. Returns a Pop3mail.Part

Decode lines and add them as content in the multipart part. Returns a Pop3mail.Part

Parse multipart Content-Disposition header line. Returns a Pop3mail.Part

Finish parsing multipart header lines and start decode of the part content. Returns a Pop3mail.Part

Parse multipart header lines. Returns a Pop3mail.Part

Ignore a multipart header line. Returns a Pop3mail.Part

Parse multipart Content-Transfer-Encoding header line. Returns a Pop3mail.Part

Skip an unknown multipart header line. Logs a warning. Returns a Pop3mail.Part

Functions

@spec decode(String.t(), String.t()) :: binary()

Return decoded text as binary.

encoding - For example: base64, quoted-printable, 7bit, 8bit, etc.

@spec decode_base64!(String.t()) :: binary()

Return decoded text as binary.

text - base64 encoded text.

Link to this function

decode_lines(encoding, lines)

View Source
@spec decode_lines(String.t(), [String.t()]) :: String.t()

Return decoded lines as binary.

encoding - For example: base64, quoted-printable, 7bit, 8bit, etc.

Link to this function

extract_and_set_filename(multipart_part, content_parameters, parametername)

View Source
@spec extract_and_set_filename(Pop3mail.Part.t(), [String.t()], String.t()) ::
  Pop3mail.Part.t()

Extract (file-)name from Content-Disposition value or Content-Type value. Returns Pop3mail.Part with filled-in filename and filename_charset.

Example of Content-Disposition header line:

Content-Disposition: attachment; filename=abc.pdf

RFC 2231 example:

filename*0*=us-ascii'en'This%20is%20even%20more%20<br> filename*1*=%2A%2A%2Afun%2A%2A%2A%20<br> filename*2="isn't it!"

Link to this function

get_param_number(key_value)

View Source
@spec get_param_number(String.t()) :: String.t()

Get parameter number of key_value. key_value - format must be: key=value or key<parameter number>=value or key*=value. Returns string. Can be empty.

@spec get_value(String.t()) :: String.t()

Get value of key_value. key_value - format must be: key=value or key<number>=value or key*=value.

Link to this function

is_multipart?(multipart_part)

View Source
@spec is_multipart?(Pop3mail.Part.t()) :: boolean()

Is this part a multipart? Looks if the media_type starts with multipart/.

It could be multipart/alternative, multipart/relative or multipart/mixed.

multipart_part - Pop3mail.Part

Link to this function

lines_continued(line1, list)

View Source
@spec lines_continued(String.t(), [String.t()]) :: {String.t(), [String.t()]}

A multipart header line can continue on the next line. When next line starts with a tab-character or when there is a opening double quote not closed yet.

Link to this function

parse_content(multipart_part)

View Source
@spec parse_content(Pop3mail.Part.t()) :: [Pop3mail.Part.t()]

Parse multipart content. Returns a flattened list of Pop3mail.Part's

This is recursively called for each multipart part, e.g. parse_content calls itself

multipart_part - Pop3mail.Part input.

Link to this function

parse_content_type(multipart_part, content_type)

View Source
@spec parse_content_type(Pop3mail.Part.t(), String.t()) :: Pop3mail.Part.t()

Parse multipart Content-Type header line. It can contain media_type, charset, (file-)name and boundary. Returns a Pop3mail.Part

multipart_part - Pop3mail.Part input

Link to this function

parse_content_type_parameters(multipart_part, content_type_parameters)

View Source
@spec parse_content_type_parameters(Pop3mail.Part.t(), [String.t()]) ::
  Pop3mail.Part.t()

Parse value of content-type header line. It can contain media_type, charset, (file-)name and boundary. Returns a Pop3mail.Part

  • multipart_part - Pop3mail.Part input
  • content_type_parameters - list of parameters in the format key=value
Link to this function

parse_disposition(multipart_part, disposition)

View Source
@spec parse_disposition(Pop3mail.Part.t(), String.t()) :: Pop3mail.Part.t()

Parse multipart Content-Disposition header line. This is either inline or attachment, and it can contain a filename. Returns a Pop3mail.Part

multipart_part - Pop3mail.Part input

Link to this function

parse_disposition_parameters(multipart_part, disposition_parameters)

View Source
@spec parse_disposition_parameters(Pop3mail.Part.t(), [String.t()]) ::
  Pop3mail.Part.t()

Parse value of Content-Disposition header line. This is either inline or attachment, and it can contain a filename. Returns a Pop3mail.Part

  • multipart_part - Pop3mail.Part input
  • disposition_parameters - list of parameters in the format key=value
Link to this function

parse_multipart(boundary_name, raw_content, path)

View Source
@spec parse_multipart(String.t(), String.t(), String.t()) :: [Pop3mail.Part.t()]

Parse the boundary in the multipart content.

  • raw_content - multipart content
  • boundary_name - multipart boundary to search for
  • path - path in the multipart hierarchy. For example: relative/alternative
Link to this function

parse_part(arg, boundary_name, path)

View Source
@spec parse_part({String.t(), integer()}, String.t(), String.t()) :: [
  Pop3mail.Part.t()
]

Parse a part of the multipart content.

  • {part, index} - Numbered part content. Index starts at 1 for part 1 in a multipart.
  • boundary_name - multipart boundary name
  • path - path in the multipart hierarchy. For example: relative/alternative
Link to this function

parse_part_content_id(multipart_part, encoding, list)

View Source
@spec parse_part_content_id(Pop3mail.Part.t(), String.t(), [String.t()]) ::
  Pop3mail.Part.t()

Parse multipart Content-ID header line. Returns a Pop3mail.Part

  • multipart_part - Pop3mail.Part input
  • encoding - For example: base64, quoted-printable, 7bit, 8bit, etc.
  • list - lines
Link to this function

parse_part_content_location(multipart_part, encoding, list)

View Source
@spec parse_part_content_location(Pop3mail.Part.t(), String.t(), [String.t()]) ::
  Pop3mail.Part.t()

Parse multipart Content-Location header line as defined in RFC 2557. Returns a Pop3mail.Part

  • multipart_part - Pop3mail.Part input
  • encoding - For example: base64, quoted-printable, 7bit, 8bit, etc.
  • list - lines
Link to this function

parse_part_content_type(multipart_part, encoding, list)

View Source
@spec parse_part_content_type(Pop3mail.Part.t(), String.t(), [String.t()]) ::
  Pop3mail.Part.t()

Parse multipart Content-Type header line. It can contain media_type, charset, (file-)name and boundary. Returns a Pop3mail.Part

  • multipart_part - Pop3mail.Part input
  • encoding - For example: base64, quoted-printable, 7bit, 8bit, etc.
  • list - lines
Link to this function

parse_part_decode(multipart_part, encoding, lines)

View Source
@spec parse_part_decode(Pop3mail.Part.t(), String.t(), [String.t()]) ::
  Pop3mail.Part.t()

Decode lines and add them as content in the multipart part. Returns a Pop3mail.Part

Is called after all multipart header lines are parsed.

  • multipart_part - Pop3mail.Part input
  • encoding - For example: base64, quoted-printable, 7bit, 8bit, etc.
  • lines - part content splitted in lines
Link to this function

parse_part_disposition(multipart_part, encoding, list)

View Source
@spec parse_part_disposition(Pop3mail.Part.t(), String.t(), [String.t()]) ::
  Pop3mail.Part.t()

Parse multipart Content-Disposition header line. Returns a Pop3mail.Part

  • multipart_part - Pop3mail.Part input
  • encoding - For example: base64, quoted-printable, 7bit, 8bit, etc.
  • list - lines
Link to this function

parse_part_finish(multipart_part, encoding, list)

View Source
@spec parse_part_finish(Pop3mail.Part.t(), String.t(), [String.t()]) ::
  Pop3mail.Part.t()

Finish parsing multipart header lines and start decode of the part content. Returns a Pop3mail.Part

  • multipart_part - Pop3mail.Part input
  • encoding - For example: base64, quoted-printable, 7bit, 8bit, etc.
  • list - lines
Link to this function

parse_part_lines(multipart_part, encoding, list)

View Source
@spec parse_part_lines(Pop3mail.Part.t(), String.t(), [String.t()]) ::
  Pop3mail.Part.t()

Parse multipart header lines. Returns a Pop3mail.Part

  • multipart_part - Pop3mail.Part input
  • encoding - For example: base64, quoted-printable, 7bit, 8bit, etc.
  • list - lines
Link to this function

parse_part_skip(multipart_part, encoding, list)

View Source
@spec parse_part_skip(Pop3mail.Part.t(), String.t(), [String.t()]) ::
  Pop3mail.Part.t()

Ignore a multipart header line. Returns a Pop3mail.Part

  • multipart_part - Pop3mail.Part input
  • encoding - For example: base64, quoted-printable, 7bit, 8bit, etc.
  • list - lines
Link to this function

parse_part_transfer_encoding(multipart_part, _, list)

View Source
@spec parse_part_transfer_encoding(Pop3mail.Part.t(), String.t(), [String.t()]) ::
  Pop3mail.Part.t()

Parse multipart Content-Transfer-Encoding header line. Returns a Pop3mail.Part

  • multipart_part - Pop3mail.Part input
  • encoding - For example: base64, quoted-printable, 7bit, 8bit, etc.
  • list - lines
Link to this function

parse_part_unknown_header(multipart_part, encoding, list)

View Source
@spec parse_part_unknown_header(Pop3mail.Part.t(), String.t(), [String.t()]) ::
  Pop3mail.Part.t()

Skip an unknown multipart header line. Logs a warning. Returns a Pop3mail.Part

  • multipart_part - Pop3mail.Part input
  • encoding - For example: base64, quoted-printable, 7bit, 8bit, etc.
  • list - lines