Project

General

Profile

« Previous | Next » 

Revision 5161

strings.py: json_encode(): Fixed bug where '\n' and '\r' also needed to be encoded

View differences:

lib/strings.py
100 100
    str_ = str_.replace(quote, quote_esc)
101 101
    return str_
102 102

  
103
def json_encode(str_): return esc_quotes(str_, '"')
103
json_encode_map = [
104
    ('\n', r'\n'),
105
    ('\r', r'\r'),
106
]
104 107

  
108
def json_encode(str_):
109
    return replace_all(json_encode_map, esc_quotes(str_, '"'))
110

  
105 111
def esc_for_mogrify(query):
106 112
    '''Escapes a query right before being passed to a mogrifying function.'''
107 113
    return query.replace('%', '%%')

Also available in: Unified diff