def safe_minidom_parse_string(xml_string):
    """Parse an XML string using minidom safely."""
    try:
        return minidom.parseString(xml_string, parser=ProtectedExpatParser())
    except (sax.SAXParseException, __HOLE__,
            expat.ExpatError, LookupError) as e:
        # NOTE(Vijaya Erukala): XML input such as
        #                      <?xml version="1.0" encoding="TF-8"?>
        #                      raises LookupError: unknown encoding: TF-8
        raise exception.MalformedRequestBody(reason=str(e))
dataset/ETHPy150Open openstack/rack/rack/api/xmlutil.py/safe_minidom_parse_string