def __call__(self, data, **metadata): try: data = data.decode("ascii", "strict") except ValueError: return None d = url.decode(data) return "URLEncoded form", base.format_pairs(d)
def __call__(self, data, **metadata): try: data = data.decode("ascii", "strict") except ValueError: return None d = url.decode(data) return "URLEncoded form", format_dict(multidict.MultiDict(d))
def _decode(self, data, **metadata): try: if type(data) is not str: data = data.decode("ascii", "strict") if not data.startswith('http'): raise ValueError("[Phorcys] Failed to parse input.") data = url.decode(data) if not data: raise ValueError("[Phorcys] Failed to parse input.") for (k, v) in data: child = Layer(True) child.human_readable = True child.parent = self.layer child.raw_data = v child.name = k child.lines = [v] self.layer.lines.append('%s=%s' % (k, v)) self.layer.add_extracted_layer(child) except: raise ValueError("[Phorcys] Failed to parse input.")
def _get_urlencoded_form(self): is_valid_content_type = "application/x-www-form-urlencoded" in self.headers.get( "content-type", "").lower() if is_valid_content_type: return tuple(url.decode(self.get_text(strict=False))) return ()
def _get_query(self): query = urllib.parse.urlparse(self.url).query return tuple(url.decode(query))
def test_decode(): s = "one=two&three=four" assert len(url.decode(s)) == 2 assert url.decode(surrogates)