KMIME Library
Classes | |
class | Base64Codec |
class | BinaryCodec |
class | BoolFlags |
class | CharFreq |
class | Codec |
class | Content |
class | ContentIndex |
class | DateFormatter |
class | Decoder |
class | EightBitCodec |
class | Encoder |
class | HeaderFactory |
class | IdentityCodec |
class | KAutoDeleteHash |
class | Message |
class | QuotedPrintableCodec |
class | Rfc2047BEncodingCodec |
class | Rfc2047QEncodingCodec |
class | Rfc2231EncodingCodec |
class | SevenBitCodec |
class | UUCodec |
Functions | |
void | addQuotes (QByteArray &str, bool forceQuotes) |
void | addQuotes (QString &str, bool forceQuotes) |
template<class StringType , class CharType , class CharConverterType , class StringConverterType , class ToString > | |
void | addQuotes_impl (StringType &str, bool forceQuotes) |
QString | balanceBidiState (const QString &input) |
static char | binToHex (uchar value) |
QByteArray | cachedCharset (const QByteArray &name) |
QByteArray | cachedLanguage (const QByteArray &name) |
QByteArray | CRLFtoLF (const QByteArray &s) |
QByteArray | CRLFtoLF (const char *s) |
QString | decodeRFC2047String (const QByteArray &src, QByteArray &usedCS, const QByteArray &defaultCS=QByteArray(), bool forceCS=false) |
QString | decodeRFC2047String (const QByteArray &src) |
QString | decodeRFC2231String (const QByteArray &src, QByteArray &usedCS, const QByteArray &defaultCS=QByteArray(), bool forceCS=false) |
QString | decodeRFC2231String (const QByteArray &src) |
QByteArray | encodeRFC2047Sentence (const QString &src, const QByteArray &charset) |
QByteArray | encodeRFC2047String (const QString &src, const QByteArray &charset, bool addressHeader=false, bool allow8bitHeaders=false) |
QByteArray | encodeRFC2231String (const QString &src, const QByteArray &charset) |
QList< Headers::contentEncoding > | encodingsForData (const QByteArray &data) |
QByteArray | extractHeader (const QByteArray &src, const QByteArray &name) |
QList< QByteArray > | extractHeaders (const QByteArray &src, const QByteArray &name) |
QString | fallbackCharEncoding () |
int | findHeaderLineEnd (const QByteArray &src, int &dataBegin, bool *folded) |
bool | hasAttachment (Content *content) |
static uchar | highNibble (uchar ch) |
int | indexOfHeader (const QByteArray &src, const QByteArray &name, int &end, int &dataBegin, bool *folded) |
static bool | isCryptoPart (Content *content) |
bool | isEncrypted (Message *message) |
bool | isInvitation (Content *content) |
bool | isSigned (Message *message) |
bool | isUsAscii (const QString &s) |
static bool | keep (uchar ch) |
QByteArray | LFtoCRLF (const QByteArray &s) |
QByteArray | LFtoCRLF (const char *s) |
static uchar | lowNibble (uchar ch) |
QByteArray | multiPartBoundary () |
QString | nameForEncoding (KMime::Headers::contentEncoding enc) |
static int | QuotedPrintableDecoder_maxDecodedSizeFor (int insize, bool withCRLF) |
QString | removeBidiControlChars (const QString &input) |
void | removeHeader (QByteArray &header, const QByteArray &name) |
void | removeQuots (QByteArray &str) |
void | removeQuots (QString &str) |
void | setFallbackCharEncoding (const QString &fallbackCharEnc) |
void | setUseOutlookAttachmentEncoding (bool violateStandard) |
QByteArray | unfoldHeader (const QByteArray &header) |
QByteArray | uniqueString () |
bool | useOutlookAttachmentEncoding () |
static uchar | uuDecode (uchar c) |
Detailed Description
Contains all the KMIME library global classes, objects, and functions.
Function Documentation
void KMime::addQuotes | ( | QByteArray & | str, |
bool | forceQuotes | ||
) |
Converts the given string into a quoted-string if the string contains any special characters (ie.
one of ()<>@,.;:[]=").
- Parameters
-
str us-ascii string to work on. forceQuotes if true
, always add quote characters.
Definition at line 848 of file kmime_util.cpp.
void KMime::addQuotes | ( | QString & | str, |
bool | forceQuotes | ||
) |
Overloaded method, behaves same as the above.
- Since
- 4.5
Definition at line 853 of file kmime_util.cpp.
QString KMime::balanceBidiState | ( | const QString & | input | ) |
Makes sure that the bidirectional state at the end of the string is the same as at the beginning of the string.
This is useful so that Unicode control characters that can change the text direction can not spill over to following strings.
As an example, consider a mailbox in the form "display name" local. If the display name here contains unbalanced control characters that change the text direction, it would also have an effect on the addrspec, which could lead to spoofing. @dom ain.c om
By passing the display name to this function, one can make sure that no change of the bidi state can spill over to the next strings, in this case the addrspec.
Example: The string "Hello <RLO>World" is unbalanced, as it contains a right-to-left override character, which is never followed by a <PDF>, the "pop directional formatting" character. This function adds the missing <PDF> at the end, and the output of this function would be "Hello <RLO>World<PDF>".
Example of spoofing: Consider "Firstname Lastname<RLO>" moc.m. Because of the RLO, it is displayed as "Firstname Lastname <moc.rekcatta@victim.com>", which spoofs the domain name. By passing "Firstname Lastname<RLO>" to this function, one can balance the <RLO>, leading to "Firstname Lastname<RLO><PDF>", so the whole mailbox is displayed correctly as "Firstname Lastname" itci v@att acke r.commoc.m again. itci v@att acke r.com
See http://unicode.org/reports/tr9 for more information on bidi control chars.
- Parameters
-
input the display name of a mailbox, which is checked for unbalanced Unicode direction control characters
- Returns
- the display name which now contains a balanced state of direction control characters
Note that this function does not do any parsing related to mailboxes, it only works on plain strings. Therefore, passing the complete mailbox will not lead to any results, only the display name should be passed.
- Since
- 4.5
Definition at line 858 of file kmime_util.cpp.
|
inlinestatic |
Converts a 4-bit value
into its hexadecimal characater representation.
So input of value [0,15] returns ['0','1',... 'F']. Input values greater than 15 will produce undesired results.
- Parameters
-
value is an unsigned character containing the 4-bit input value.
Definition at line 54 of file kmime_codec_qp.cpp.
QByteArray KMime::cachedCharset | ( | const QByteArray & | name | ) |
Consult the charset cache.
Only used for reducing mem usage by keeping strings in a common repository.
- Parameters
-
name
Definition at line 60 of file kmime_util.cpp.
QByteArray KMime::cachedLanguage | ( | const QByteArray & | name | ) |
Consult the language cache.
Only used for reducing mem usage by keeping strings in a common repository.
- Parameters
-
name
Definition at line 73 of file kmime_util.cpp.
QByteArray KMime::CRLFtoLF | ( | const QByteArray & | s | ) |
Converts all occurrences of "\r\n" (CRLF) in s
to "\n" (LF).
This function is expensive and should be used only if the mail will be stored locally. All decode functions can cope with both line endings.
- Parameters
-
s source string containing CRLF's
- Returns
- the string with CRLF's substitued for LF's
- See Also
- CRLFtoLF(const char*) LFtoCRLF
Definition at line 773 of file kmime_util.cpp.
QByteArray KMime::CRLFtoLF | ( | const char * | s | ) |
Converts all occurrences of "\r\n" (CRLF) in s
to "\n" (LF).
This function is expensive and should be used only if the mail will be stored locally. All decode functions can cope with both line endings.
- Parameters
-
s source string containing CRLF's
- Returns
- the string with CRLF's substitued for LF's
- See Also
- CRLFtoLF(const QCString&) LFtoCRLF
Definition at line 780 of file kmime_util.cpp.
QString KMime::decodeRFC2047String | ( | const QByteArray & | src, |
QByteArray & | usedCS, | ||
const QByteArray & | defaultCS = QByteArray() , |
||
bool | forceCS = false |
||
) |
Decodes string src
according to RFC2047,i.e., the construct =?charset?[qb]?encoded?=.
- Parameters
-
src source string. usedCS the detected charset is returned here defaultCS the charset to use in case the detected one isn't known to us. forceCS force the use of the default charset.
- Returns
- the decoded string.
Definition at line 204 of file kmime_util.cpp.
QString KMime::decodeRFC2047String | ( | const QByteArray & | src | ) |
Decode string src
according to RFC2047 (ie.
the =?charset?[qb]?encoded?= construct).
- Parameters
-
src source string.
- Returns
- the decoded string.
Definition at line 260 of file kmime_util.cpp.
QString KMime::decodeRFC2231String | ( | const QByteArray & | src, |
QByteArray & | usedCS, | ||
const QByteArray & | defaultCS = QByteArray() , |
||
bool | forceCS = false |
||
) |
Decodes string src
according to RFC2231.
- Parameters
-
src source string. usedCs the detected charset is returned here defaultCS the charset to use in case the detected one isn't known to us. forceCS force the use of the default charset.
- Returns
- the decoded string.
Definition at line 490 of file kmime_util.cpp.
QString KMime::decodeRFC2231String | ( | const QByteArray & | src | ) |
Decode string src
according to RFC2231 (ie.
the charset'lang'encoded construct).
- Parameters
-
src source string.
- Returns
- the decoded string.
Definition at line 535 of file kmime_util.cpp.
QByteArray KMime::encodeRFC2047String | ( | const QString & | src, |
const QByteArray & | charset, | ||
bool | addressHeader = false , |
||
bool | allow8bitHeaders = false |
||
) |
Encodes string src
according to RFC2047 using charset charset
.
This function also makes commas, quotes and other characters part of the encoded name, for example the string "Jöhn Döe" <john@"> would be encoded as <encoded word for "Jöhn Döe"> exam ple.c omjohn@, i.e. the opening and closing quote mark would be part of the encoded word. Therefore don't use this function for input strings that contain semantically meaningful characters, like the quoting marks in this example. exam ple.c om
- Parameters
-
src source string. charset charset to use. If it can't encode the string, UTF-8 will be used instead. addressHeader if this flag is true, all special chars like <,>,[,],... will be encoded, too. allow8bitHeaders if this flag is true, 8Bit headers are allowed.
- Returns
- the encoded string.
Definition at line 268 of file kmime_util.cpp.
QByteArray KMime::encodeRFC2231String | ( | const QString & | src, |
const QByteArray & | charset | ||
) |
Encodes string src
according to RFC2231 using charset charset
.
- Parameters
-
src source string. charset charset to use.
- Returns
- the encoded string.
Definition at line 428 of file kmime_util.cpp.
QList< KMime::Headers::contentEncoding > KMime::encodingsForData | ( | const QByteArray & | data | ) |
Returns a list of encodings that can correctly encode the data
.
@ since 4.4
Definition at line 110 of file kmime_util.cpp.
QByteArray KMime::extractHeader | ( | const QByteArray & | src, |
const QByteArray & | name | ||
) |
Tries to extract the header with name name
from the string src
, unfolding it if necessary.
- Parameters
-
src the source string. name the name of the header to search for.
- Returns
- the first instance of the header
name
insrc
or a null QCString if no such header was found.
Definition at line 713 of file kmime_util.cpp.
QList< QByteArray > KMime::extractHeaders | ( | const QByteArray & | src, |
const QByteArray & | name | ||
) |
Tries to extract the headers with name name
from the string src
, unfolding it if necessary.
- Parameters
-
src the source string. name the name of the header to search for.
- Returns
- all instances of the header
name
insrc
- Since
- 4.2
Definition at line 736 of file kmime_util.cpp.
QString KMime::fallbackCharEncoding | ( | ) |
Retrieve the set fallback charset if there is one set.
- Returns
- The name of the fallback encoding, if one was set, otherwise an empty QString.
- Since
- 4.5
Definition at line 188 of file kmime_util.cpp.
bool KMime::hasAttachment | ( | Content * | content | ) |
Returns whether or not the given MIME node contains an attachment part.
This function will recursively parse the MIME tree looking for a suitable attachment and return true if one is found.
Definition at line 941 of file kmime_util.cpp.
|
inlinestatic |
Returns the high-order 4 bits of an 8-bit value in another 8-bit value.
- Parameters
-
ch is an unsigned character containing the 8-bit input value.
Definition at line 67 of file kmime_codec_qp.cpp.
bool KMime::isEncrypted | ( | Message * | message | ) |
Returns whether or not the given message
is partly or fully encrypted.
- Since
- 4.6
Definition at line 995 of file kmime_util.cpp.
bool KMime::isInvitation | ( | Content * | content | ) |
Returns whether or not the given MIME content
is an invitation message of the iTIP protocol.
- Since
- 4.6
Definition at line 1014 of file kmime_util.cpp.
bool KMime::isSigned | ( | Message * | message | ) |
Returns whether or not the given message
is partly or fully signed.
- Since
- 4.6
Definition at line 975 of file kmime_util.cpp.
bool KMime::isUsAscii | ( | const QString & | s | ) |
Checks whether s
contains any non-us-ascii characters.
- Parameters
-
s
Definition at line 86 of file kmime_util.cpp.
|
inlinestatic |
Returns true if the specified value is a not Control character or question mark; else true.
- Parameters
-
ch is an unsigned character containing the 8-bit input value.
Definition at line 86 of file kmime_codec_qp.cpp.
QByteArray KMime::LFtoCRLF | ( | const QByteArray & | s | ) |
Converts all occurrences of "\n" (LF) in s
to "\r\n" (CRLF).
This function is expensive and should be used only if the mail will be transmitted as an RFC822 message later. All decode functions can cope with and all encode functions can optionally produce both line endings, which is much faster.
- Parameters
-
s source string containing CRLF's
- Returns
- the string with CRLF's substitued for LF's
- See Also
- CRLFtoLF(const QCString&) LFtoCRLF
Definition at line 786 of file kmime_util.cpp.
|
inlinestatic |
Returns the low-order 4 bits of an 8-bit value in another 8-bit value.
- Parameters
-
ch is an unsigned character containing the 8-bit input value.
Definition at line 76 of file kmime_codec_qp.cpp.
QByteArray KMime::multiPartBoundary | ( | ) |
Constructs a random string (sans leading/trailing "–") that can be used as a multipart delimiter (ie.
as boundary
parameter to a multipart/... content-type).
- Returns
- the randomized string.
- See Also
- uniqueString
Definition at line 568 of file kmime_util.cpp.
QString KMime::nameForEncoding | ( | KMime::Headers::contentEncoding | enc | ) |
Returns a user-visible string for a contentEncoding, for example "quoted-printable" for CEquPr.
@ since 4.4 TODO should they be i18n'ed?
Definition at line 97 of file kmime_util.cpp.
QString KMime::removeBidiControlChars | ( | const QString & | input | ) |
Similar to the above function.
Instead of trying to balance the Bidi chars, it outright removes them from the string.
Reason: KHTML seems to ignore the PDF character, so adding them doesn't fix things :(
Definition at line 904 of file kmime_util.cpp.
void KMime::removeQuots | ( | QByteArray & | str | ) |
Removes quote (DQUOTE) characters and decodes "quoted-pairs" (ie.
backslash-escaped characters)
- Parameters
-
str the string to work on.
- See Also
- addQuotes
Definition at line 817 of file kmime_util.cpp.
void KMime::removeQuots | ( | QString & | str | ) |
Removes quote (DQUOTE) characters and decodes "quoted-pairs" (ie.
backslash-escaped characters)
- Parameters
-
str the string to work on.
- See Also
- addQuotes
Definition at line 822 of file kmime_util.cpp.
void KMime::setFallbackCharEncoding | ( | const QString & | fallbackCharEnc | ) |
Set the fallback charset to use when decoding RFC2047-encoded headers.
If decoding according to the RFC fails, then the fallback encoding is used instead.
- Parameters
-
fallbackCharEnc Name of fallback character encoding to use.
- Since
- 4.5
Definition at line 183 of file kmime_util.cpp.
void KMime::setUseOutlookAttachmentEncoding | ( | bool | violateStandard | ) |
Set whether or not to use outlook compatible attachment filename encoding.
Outlook fails to properly adhere to the RFC2322 standard for parametrized header fields, and instead is only able to read and write attachment filenames encoded in RFC2047-style. This will create mails that are not standards-compliant!
- Parameters
-
violateStandard Whether or not to use outlook-compatible attachment filename encodings.
- Since
- 4.5
Definition at line 193 of file kmime_util.cpp.
QByteArray KMime::unfoldHeader | ( | const QByteArray & | header | ) |
Unfolds the given header if necessary.
- Parameters
-
header The header to unfold.
Definition at line 573 of file kmime_util.cpp.
QByteArray KMime::uniqueString | ( | ) |
Uses current time, pid and random numbers to construct a string that aims to be unique on a per-host basis (ie.
for the local part of a message-id or for multipart boundaries.
- Returns
- the unique string.
- See Also
- multiPartBoundary
Definition at line 541 of file kmime_util.cpp.
bool KMime::useOutlookAttachmentEncoding | ( | ) |
Retrieve whether or not to use outlook compatible encodings for attachments.
Definition at line 198 of file kmime_util.cpp.
Variable Documentation
const uchar KMime::aTextMap[16] |
Definition at line 160 of file kmime_util.cpp.
const uchar KMime::eTextMap[16] |
Definition at line 176 of file kmime_util.cpp.
const uchar KMime::specialsMap[16] |
Definition at line 144 of file kmime_util.cpp.
const uchar KMime::tSpecialsMap[16] |
Definition at line 152 of file kmime_util.cpp.
const uchar KMime::tTextMap[16] |
Definition at line 168 of file kmime_util.cpp.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:25:46 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.