'Check the argument sent to a jQuery DOM insertion function (e.g.
append()) to check if it is safe.
Safe arguments include:
- the argument can end with ".el", ".$el" (with no concatenation)
- the argument can be a single variable ending in "El" or starting with
"$". For example, "testEl" or "$test".
- the argument can be a single string literal with no HTML tags
- the argument can be a call to $() with the first argument a string
literal with a single HTML tag.  For example, ".append($(\'<br/>\'))"
or ".append($(\'<br/>\'))".
- the argument can be a call to HtmlUtils.xxx(html).toString()
Arguments:
argument: The argument sent to the jQuery function (e.g.
append(argument)).
Returns:
True if the argument is safe, and False otherwise.'

def _is_jquery_argument_safe(self, argument):

    match_variable_name = re.search('[_$a-zA-Z]+[_$a-zA-Z0-9]*', argument)
    if ((match_variable_name is not None) and (match_variable_name.group() == argument)):
        if (argument.endswith('El') or argument.startswith('$')):
            return True
    elif (argument.startswith('"') or argument.startswith("'")):
        string = ParseString(argument, 0, len(argument))
        if ((string.string == argument) and ('<' not in argument)):
            return True
    elif argument.startswith('$('):
        match = re.search('\\$\\(\\s*[\'"]<[a-zA-Z0-9]+\\s*[/]?>[\'"]\\s*[,)]', argument)
        if (match is not None):
            return True
    elif self._is_jquery_argument_safe_html_utils_call(argument):
        return True
    elif ('+' not in argument):
        if (argument.endswith('.el') or argument.endswith('.$el')):
            return True
    return False
