l.s.w.escaping : module documentation

Part of lp.services.webapp

No module docstring
Function html_escape Performs translation and sanitizes any HTML present in the message.
Function html_unescape Reverses the transformation performed by html_escape.
Function translate_if_i18n Translate an internationalized object, returning the result.
def html_escape(message):
Performs translation and sanitizes any HTML present in the message.

DO NOT USE THIS DIRECTLY UNLESS YOU ARE SURE YOU NEED TO.

There is rarely a good reason to use this directly instead of going via structured().

A plain string message will be sanitized ("&", "<" and ">" are converted to HTML-safe sequences). Passing a message that provides the IStructuredString interface will return a unicode string that has been properly escaped. Passing an instance of a Zope internationalized message will cause the message to be translated, then santizied.

ParametersmessageThis may be a string, zope.i18n.Message, zope.i18n.MessageID, or an instance of IStructuredString.
def html_unescape(message):
Reverses the transformation performed by html_escape.

DO NOT USE THIS EXCEPT IN LEGACY CODE.

Converts the 5 entities references produced by html_escape into their original form. There is almost no reason to ever do this.

def translate_if_i18n(obj_or_msgid):
Translate an internationalized object, returning the result.

Returns any other type of object untouched.

API Documentation for Launchpad, generated by pydoctor at 2018-05-25 00:00:05.