Wt  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Enumerations | Functions
Wt::Utils Namespace Reference

Namespace with utility functions. More...

Enumerations

enum  HtmlEncodingFlag { EncodeNewLines = 0x1 }
 An enumeration for HTML encoding flags. More...

Functions

WT_API std::string md5 (const std::string &data)
 Computes an MD5 hash.
WT_API std::string sha1 (const std::string &data)
 Computes a SHA-1 hash.
WT_API std::string base64Encode (const std::string &data)
 Performs Base64-encoding of data.
WT_API std::string base64Decode (const std::string &data)
 Performs Base64-decoding of data.
WT_API std::string hexEncode (const std::string &data)
 Performs Hex-encoding of data.
WT_API std::string hexDecode (const std::string &data)
 Performs Hex-decoding of data.
WT_API std::string htmlEncode (const std::string &text, WFlags< HtmlEncodingFlag > flags=0)
 Performs HTML encoding of text.
WT_API WString htmlEncode (const WString &text, WFlags< HtmlEncodingFlag > flags=0)
 Performs HTML encoding of text.
WT_API std::string urlEncode (const std::string &text)
 Performs Url encoding (aka percentage encoding).
WT_API std::string urlDecode (const std::string &text)
 Performs Url decoding.
WT_API bool removeScript (WString &text)
 Remove tags/attributes from text that are not passive.

Detailed Description

Namespace with utility functions.

This namespace contains functions for computing message digests with cryptographic hash functions (md5, sha1), and functions that implement encoding and decoding for common encodings.

Enumeration Type Documentation

An enumeration for HTML encoding flags.

Enumerator:
EncodeNewLines 

Encode new-lines as line breaks (<br>)

Function Documentation

std::string Wt::Utils::base64Decode ( const std::string &  data)

Performs Base64-decoding of data.

This utility function implements a Base64 decoding (RFC 2045) of the data. Illegal characters are discarded and skipped.

See Also
base64Encode()
std::string Wt::Utils::base64Encode ( const std::string &  data)

Performs Base64-encoding of data.

This utility function implements a Base64 encoding (RFC 2045) of the data.

See Also
base64Decode()
std::string Wt::Utils::hexDecode ( const std::string &  data)

Performs Hex-decoding of data.

Illegal characters are discarded and skipped.

See Also
hexEncode()
std::string Wt::Utils::hexEncode ( const std::string &  data)

Performs Hex-encoding of data.

A hex-encoding outputs the value of every byte as as two-digit hexadecimal number.

See Also
hexDecode()
std::string Wt::Utils::htmlEncode ( const std::string &  text,
WFlags< HtmlEncodingFlag >  flags = 0 
)

Performs HTML encoding of text.

This utility function escapes characters so that the text can be embodied verbatim in a HTML text block.

WString Wt::Utils::htmlEncode ( const WString &  text,
WFlags< HtmlEncodingFlag >  flags = 0 
)

Performs HTML encoding of text.

This utility function escapes characters so that the text can be embodied verbatim in a HTML text block.

By default, newlines are ignored. By passing the EncodeNewLines flag, these may be encoded as line breaks (<br>).

std::string Wt::Utils::md5 ( const std::string &  data)

Computes an MD5 hash.

This utility function computes an MD5 hash, and returns the raw (binary) hash value.

See Also
sha1()
bool Wt::Utils::removeScript ( WString &  text)

Remove tags/attributes from text that are not passive.

This removes tags and attributes from XHTML-formatted text that do not simply display something but may trigger scripting, and could have been injected by a malicious user for Cross-Site Scripting (XSS).

This method is used by the library to sanitize XHTML-formatted text set in WText, but it may also be useful outside the library to sanitize user content when directly using JavaScript.

Modifies the text if needed. When the text is not proper XML, returns false.

std::string Wt::Utils::sha1 ( const std::string &  data)

Computes a SHA-1 hash.

This utility function computes a SHA-1 hash, and returns the raw (binary) hash value.

See Also
md5()
std::string Wt::Utils::urlDecode ( const std::string &  text)

Performs Url decoding.

This utility function percent encodes a text so that it can be embodied verbatim in a URL (e.g. as a fragment).

Note
To url decode a unicode string, the de-facto standard practice is to interpret the string as a UTF-8 encoded string.
See Also
WString::fromUTF8(), urlEncode()
std::string Wt::Utils::urlEncode ( const std::string &  text)

Performs Url encoding (aka percentage encoding).

This utility function percent encodes a text so that it can be embodied verbatim in a URL (e.g. as a fragment).

Note
To url encode a unicode string, the de-facto standard practice is to encode a UTF-8 encoded string.
See Also
WString::toUTF8(), urlDecode()

Generated on Mon Aug 25 2014 for the C++ Web Toolkit (Wt) by doxygen 1.8.1.2