def cleaner(dummy, value, *_):
    'Cleans out unsafe HTML tags.\n\n  Uses bleach and unescape until it reaches a fix point.\n\n  Args:\n    dummy: unused, sqalchemy will pass in the model class\n    value: html (string) to be cleaned\n  Returns:\n    Html (string) without unsafe tags.\n  '
    if (value is None):
        return value
    if (not isinstance(value, basestring)):
        return value
    value = unicode(value)
    buggy_strings = re.finditer(BUGGY_STRINGS_PATTERN, PARSER.unescape(value))
    while True:
        lastvalue = value
        value = PARSER.unescape(CLEANER.clean(value))
        if (value == lastvalue):
            break
    if buggy_strings:
        backup_value = value
        updated_buggy_strings = re.finditer(BUGGY_STRINGS_PATTERN, value)
        for match in updated_buggy_strings:
            try:
                old_value = buggy_strings.next().group()
                (start, finish) = match.span()
                value = ((value[:start] + old_value) + value[finish:])
            except StopIteration:
                return backup_value
    return value
Cleans out unsafe HTML tags.

Uses bleach and unescape until it reaches a fix point.

Args:
  dummy: unused, sqalchemy will pass in the model class
  value: html (string) to be cleaned
Returns:
  Html (string) without unsafe tags.
def cleaner(dummy, value, *_):
    'Cleans out unsafe HTML tags.\n\n  Uses bleach and unescape until it reaches a fix point.\n\n  Args:\n    dummy: unused, sqalchemy will pass in the model class\n    value: html (string) to be cleaned\n  Returns:\n    Html (string) without unsafe tags.\n  '
    if (value is None):
        return value
    if (not isinstance(value, basestring)):
        return value
    value = unicode(value)
    buggy_strings = re.finditer(BUGGY_STRINGS_PATTERN, PARSER.unescape(value))
    while True:
        lastvalue = value
        value = PARSER.unescape(CLEANER.clean(value))
        if (value == lastvalue):
            break
    if buggy_strings:
        backup_value = value
        updated_buggy_strings = re.finditer(BUGGY_STRINGS_PATTERN, value)
        for match in updated_buggy_strings:
            try:
                old_value = buggy_strings.next().group()
                (start, finish) = match.span()
                value = ((value[:start] + old_value) + value[finish:])
            except StopIteration:
                return backup_value
    return value