Ticket #5611: parsesql.diff

File parsesql.diff, 1.4 KB (added by Martin Kanerva, 16 years ago)

Another workaround

  • django/http/__init__.py

     
    99    from mod_python.util import parse_qsl
    1010except ImportError:
    1111    from cgi import parse_qsl
     12# whilst being efficient, the mod_python version also breaks on certain data, so we need this for those cases
     13from cgi import parse_qsl as parse_qsl_cgi
    1214
    1315from django.utils.datastructures import MultiValueDict, ImmutableList
    1416from django.utils.encoding import smart_str, iri_to_uri, force_unicode
     
    144146            from django.conf import settings
    145147            encoding = settings.DEFAULT_CHARSET
    146148        self.encoding = encoding
    147         for key, value in parse_qsl((query_string or ''), True): # keep_blank_values=True
    148             self.appendlist(force_unicode(key, encoding, errors='replace'),
    149                             force_unicode(value, encoding, errors='replace'))
     149        def do_parse(parse_qsl_method):
     150            for key, value in parse_qsl_method((query_string or ''), True): # keep_blank_values=True
     151                self.appendlist(force_unicode(key, encoding, errors='replace'),
     152                                force_unicode(value, encoding, errors='replace'))
     153        try:
     154            do_parse(parse_qsl)
     155        except TypeError:
     156            do_parse(parse_qsl_cgi)
    150157        self._mutable = mutable
    151158
    152159    def _get_encoding(self):
Back to Top