def unescape(s, quote=False):
    """
    The opposite of the cgi.escape function.
    Replace escaped characters '&amp;', '&lt;' and '&gt;' with the corresponding
    regular characters. If the optional flag quote is true, the escaped quotation
    mark character ('&quot;') is also translated.
    """
    s = s.replace('&lt;', '<')
    s = s.replace('&gt;', '>')
    if quote:
        s = s.replace('&quot;', '"')
    s = s.replace('&amp;', '&')
    return s