Crate quoted_string [] [src]

This crate provides utilities to handle quoted strings as they appear in multiple mail and web related RFCs. While it is mainly based on rfc5322 (Internet Message Format). It also supports Utf8 based on rfc6532 (optional) and is compatible with quoted-strings as they appear in mime types (including in HTTP/1.1 context).

What it currently does not support are soft-line breaks of rfc5322, neither is the obsolete part of the syntax supported (for now).

The supported grammar is:

quoted-string   = DQUOTE *( *WSP qcontent) *WSP DQUOTE
qcontent = qtext / quoted-pair
qtext = %d33 / %d35-91 / %d93-126 ; printable us-ascii chars not including '\\' and '"'
quoted-pair = ("\" (VCHAR / WSP)) ; VCHAR are printable us-ascii chars
DQUPTE = '"'
WSP = ' ' / '\t'

Note that the contained CharType enum has a more fine grained differentiation then aboves grammar as it can differ between chars which are unquotable, which need to be represented as a quoted-pair ('\\' and '"') which are token chars (token of rfc2045) or tspecial chars (rfc2045) or non us-ascii chars or allowed white space chars ('\t' and ' ').

The obsolete syntax is is currently not supported. Differences would be:

  1. it would allow CTL's in qtext
  2. it would allow quoted pairs to escape CTL's, '\0', '\n', '\r'

Nevertheless this part of the syntax is obsolete and should not be generated at all. Adding opt-in support for parts parsing quoted-string is in consideration.

Modules

error

quoted-string errors

Structs

ContentChars

A iterator over chars of the content represented by the quoted strings (PartialEq<&str>)

Enums

CharType

A enum for usage in combination with the QTEXT_INFO lookup table

QuotedStringType

Indicates what kind of quoted-strings are used

Traits

AsciiCaseInsensitiveEq

Analogous to PartialEq, but with ascii case insensitive equality

ValidWithoutQuotationCheck

Used to determine 1. if the string needs quoting 2. where the first char which could require quoting appears

Functions

quote

quotes the input string returning the quoted string and if it contains non us-ascii chars.

quote_if_needed

quotes the input string if needed(RFC 5322/6532/822/2045)

unquote_unchecked

undoes quoting of given input assuming it is a valid quoted-string