Example #1
0
def escape_validation(validation):
    ending_tier = validation.get('ending_tier', 0)
    for msg in validation.get('messages', []):
        tier = msg.get('tier', -1)  # Use -1 so we know it isn't 0.
        if tier > ending_tier:
            ending_tier = tier
        if tier == 0:
            # We can't display a message if it's on tier 0.
            # Should get fixed soon in bug 617481
            msg['tier'] = 1

        msg['message'] = linkify_escape(msg['message'])

        for key in 'description', 'signing_help':
            if key in msg:
                # These may be returned as single strings, or lists of
                # strings. Turn them all into lists for simplicity
                # on the client side.
                if not isinstance(msg[key], (list, tuple)):
                    msg[key] = [msg[key]]

                msg[key] = [linkify_escape(text) for text in msg[key]]

    validation['ending_tier'] = ending_tier
    return validation
Example #2
0
def escape_validation(validation):
    ending_tier = validation.get('ending_tier', 0)
    for msg in validation.get('messages', []):
        tier = msg.get('tier', -1)  # Use -1 so we know it isn't 0.
        if tier > ending_tier:
            ending_tier = tier
        if tier == 0:
            # We can't display a message if it's on tier 0.
            # Should get fixed soon in bug 617481
            msg['tier'] = 1

        msg['message'] = linkify_escape(msg['message'])

        for key in 'description', 'signing_help':
            if key in msg:
                # These may be returned as single strings, or lists of
                # strings. Turn them all into lists for simplicity
                # on the client side.
                if not isinstance(msg[key], (list, tuple)):
                    msg[key] = [msg[key]]

                msg[key] = [linkify_escape(text) for text in msg[key]]

    validation['ending_tier'] = ending_tier
    return validation
Example #3
0
def htmlify_validation(validation):
    """Process the `message`, `description`, and `signing_help` fields into
    safe HTML, with URLs turned into links."""

    for msg in validation['messages']:
        msg['message'] = linkify_escape(msg['message'])

        for key in 'description', 'signing_help':
            if key in msg:
                # These may be returned as single strings, or lists of
                # strings. Turn them all into lists for simplicity
                # on the client side.
                if not isinstance(msg[key], (list, tuple)):
                    msg[key] = [msg[key]]

                msg[key] = [linkify_escape(text) for text in msg[key]]
Example #4
0
def htmlify_validation(validation):
    """Process the `message`, `description`, and `signing_help` fields into
    safe HTML, with URLs turned into links."""

    for msg in validation['messages']:
        msg['message'] = linkify_escape(msg['message'])

        for key in 'description', 'signing_help':
            if key in msg:
                # These may be returned as single strings, or lists of
                # strings. Turn them all into lists for simplicity
                # on the client side.
                if not isinstance(msg[key], (list, tuple)):
                    msg[key] = [msg[key]]

                msg[key] = [linkify_escape(text) for text in msg[key]]