def search_form(content, cgiuser, cgipassword, encoding='utf-8'):
    """Search for a HTML form in the given HTML content that has the given
    CGI fields. If no form is found return None.
    """
    handler = FormFinder()
    parser = htmlsax.parser(handler)
    handler.parser = parser
    parser.encoding = encoding
    # parse
    parser.feed(content)
    parser.flush()
    # break cyclic dependencies
    handler.parser = None
    parser.handler = None
    log.debug(LOG_CHECK, "Found forms %s", handler.forms)
    cginames = (cgiuser.lower(), cgipassword.lower())
    for form in handler.forms:
        for key, value in form.data.items():
            if key.lower() in cginames:
                return form
    # not found
    return None
Search for a HTML form in the given HTML content that has the given
    CGI fields. If no form is found return None.