def METHOD_NAME(self, alt_text):
    """Clean user input to prevent script injection."""
    if alt_text is not None:
        if lxml_unavailable:
            warn(
                'The lxml library is not installed, and is required to '
                'sanitize alt text for napari screenshots. Alt-text '
                'will be stripped altogether without lxml.'
            )
            return None
        # cleaner won't recognize escaped script tags, so always unescape
        # to be safe
        alt_text = html.unescape(str(alt_text))
        cleaner = Cleaner()
        try:
            doc = document_fromstring(alt_text)
            alt_text = cleaner.clean_html(doc).text_content()
        except ParserError:
            warn(
                'The provided alt text does not constitute valid html, so it was discarded.',
                stacklevel=3,
            )
            alt_text = ""
        if alt_text == "":
            alt_text = None
    return alt_text