Пример #1
0
def quote(s, is_header=False):
    if is_header:
        h = Utils.oneline(s, 'iso-8859-1')
    else:
        h = s
    h = str('').join(re.split('[\x00-\x08\x0B-\x1f]+', h))
    return Utils.uquote(
        h.replace('&', '&amp;').replace('>', '&gt;').replace('<', '&lt;'))
Пример #2
0
def quote(s, is_header=False):
    if is_header:
        h = Utils.oneline(s, 'utf-8')
    else:
        h = s

    # Remove illegal XML characters
    # Try to decode UTF-8, so that Utils.uquote can escape multibyte characters
    # correctly.
    try:
        hclean = h.decode('utf-8')
        hclean = u''.join(re.split(u'[\x00-\x08\x0B-\x1f]+', hclean))
    except UnicodeDecodeError:
        hclean = ''.join(re.split('[\x00-\x08\x0B-\x1f]+', h))
    return Utils.uquote(hclean.replace('&', '&amp;').replace('>', '&gt;').replace('<', '&lt;'))
Пример #3
0
def quote(s, is_header=False):
    if is_header:
        h = Utils.oneline(s, 'utf-8')
    else:
        h = s

    # Remove illegal XML characters
    # Try to decode UTF-8, so that Utils.uquote can escape multibyte characters
    # correctly.
    try:
        hclean = h.decode('utf-8')
        hclean = u''.join(re.split(u'[\x00-\x08\x0B-\x1f]+', hclean))
    except UnicodeDecodeError:
        hclean = ''.join(re.split('[\x00-\x08\x0B-\x1f]+', h))
    return Utils.uquote(hclean.replace('&', '&amp;').replace('>', '&gt;').replace('<', '&lt;'))