def unquote_v(self, nv): """ TODO: Do we need this? """ if len(nv) == 1: return nv else: return (nv[0], unquote(nv[1]))
def _canonical_query_string_url(self, parts): buf = '' if parts.query: qsa = parts.query.split('&') qsa = [a.split('=', 1) for a in qsa] quoted_qsa = [] for q in qsa: if len(q) == 2: quoted_qsa.append('%s=%s' % (quote( q[0], safe='-_.~'), quote(unquote(q[1]), safe='-_.~'))) elif len(q) == 1: quoted_qsa.append('%s=' % quote(q[0], safe='-_.~')) if len(quoted_qsa) > 0: quoted_qsa.sort() buf += '&'.join(quoted_qsa) return buf
def _canonical_query_string_url(self, parts): buf = '' if parts.query: qsa = parts.query.split('&') qsa = [a.split('=', 1) for a in qsa] quoted_qsa = [] for q in qsa: if len(q) == 2: quoted_qsa.append( '%s=%s' % (quote(q[0], safe='-_.~'), quote(unquote(q[1]), safe='-_.~'))) elif len(q) == 1: quoted_qsa.append('%s=' % quote(q[0], safe='-_.~')) if len(quoted_qsa) > 0: quoted_qsa.sort() buf += '&'.join(quoted_qsa) return buf
def decode_quoted_jsondoc(value): try: value = json.loads(unquote(value)) except (ValueError, TypeError): logger.debug('Error loading quoted JSON', exc_info=True) return value