import re


def user_vars(metadata_dict):
    """Returns a list of (str, str, str) from metadata's 'user_vars' field.

    Each entry in the returned list is a the name of a variable, it's value,
    and its description.

    If the 'user_vars' field is not present, an empty list is returned.  If it
    is malformed, then None is returned.
    """
    text = metadata_dict.get('user_vars')

    if not text:
        return []

    rval = []

    text = text.strip()
    entries = re.split('(\w+\s+\\[.*\\]\s+".*")\s+', text)
    entries = list(filter(None, entries))

    for entry in entries:
        m = re.match('(\w+)\s+\\[(.*)\\]\s+"(.*)"', entry)

        if not m:
            return None

        groups = m.groups()

        if len(groups) != 3:
            return None

        rval.append((groups[0], groups[1], groups[2]))

    return rval