Commit Graph

23 Commits

Author SHA1 Message Date
Aldo Cortesi
02acfb1242 Fix netlib.utils.is_valid_host
- Don't crash when passed an empty string. This translated into an actual core
crash, discovered while fuzzing with afl.
- Taking a slice of length one out of bytes returns an integer, so the check
for trailing period in this function never worked on Python3.
- Add unit tests.
2016-07-21 10:38:37 +12:00
Aldo Cortesi
b94f5fd361 Convert examples and example tests for new-style scripts
Remove the test that just loads all the example scripts for now - it's a very
low-value test, and we need to think of something better.
2016-07-14 19:54:15 +12:00
Maximilian Hils
64a867973d sni is now str, not bytes 2016-07-06 21:03:17 -07:00
Aldo Cortesi
1ffc273c94 Utils cleanups
- Move more stuff that belongs in netlib.human
- Move some stuff to near the only use
- Zap mitmproxy.utils.timestamp(). I see the rationale, but we used it
interchangeably with time.time() throughout the project. Since time.time()
dominates in the codebase and timestamp() is such low utility, away it goes.
2016-06-07 17:12:52 +12:00
Aldo Cortesi
09da1febbd Shift a bunch more string-related functions to strutils 2016-06-02 13:04:19 +12:00
Aldo Cortesi
cccdc98426 Utils reorganisation: add netlib.strutils
Extract a number of string and format-related functions to netlib.strutils.
2016-06-02 12:31:41 +12:00
Aldo Cortesi
40a030f215 Satisfy flake8 2016-05-31 19:58:28 +12:00
Aldo Cortesi
b2f63458fc Move human-friendly format functions to netlib.human, remove redundant implementations 2016-05-31 19:32:08 +12:00
Aldo Cortesi
ec34cae618 utils.multipartdecode -> http.multipart.decode
also

utils.parse_content_type -> http.headers.parse_content_type
2016-05-31 19:07:55 +12:00
Aldo Cortesi
15b2374ef9 netlib.utils.get_header_tokens -> netlib.http1.read.get_header_tokens
Placing this next to its only use.
2016-05-31 18:54:42 +12:00
Aldo Cortesi
da074bff01 isascii is unused 2016-05-31 18:51:40 +12:00
Aldo Cortesi
4e6c9c4e93 Extract url functions from netlib.utils and move to netlib.http.url 2016-05-31 18:42:56 +12:00
Aldo Cortesi
08fbe6f111 Start cleaning up netlib.utils
- Remove http2 functions, move to http2.frame
- Remove Serializable, move to netlib.basetypes
2016-05-31 17:16:31 +12:00
Thomas Kriechbaumer
d76e5ad1ee raise a more verbose error 2016-05-29 19:28:59 +02:00
Maximilian Hils
d149c447fe fix py3 tests 2016-05-25 20:31:32 -07:00
Maximilian Hils
d3477e27fa bytes_to_escaped_str: always escape single quotes 2016-05-25 20:11:34 -07:00
Maximilian Hils
7a8da48a30 escaped_str_to_bytes: support unicode on python 2 2016-05-25 19:16:02 -07:00
Maximilian Hils
44ac64aa72 add MultiDict
This commit introduces MultiDict, a multi-dictionary similar to
ODict, but with improved semantics (as in the Headers class).
MultiDict fixes a few issues that were present in the Request/Response
API. In particular, `request.cookies["foo"] = "bar"` has previously been a
no-op, as the cookies property returned a mutable _copy_ of the cookies.
2016-05-18 18:46:42 -07:00
Maximilian Hils
f1c922c652 Sanitize Print (#1135)
* sanitize strings with shell control characters

* netlib: add utilities to safe-print bytes

* escaped str: add TODO for multi-byte chars
2016-05-12 11:03:57 -06:00
Maximilian Hils
9d47d3b1ec fix #1120 2016-05-09 12:15:20 -06:00
Maximilian Hils
806aa0f41c improve .replace() and move it into netlib 2016-04-02 14:38:33 +02:00
Maximilian Hils
4ee8808b44 add Serializeable.copy 2016-04-02 13:50:53 +02:00
Maximilian Hils
d33d3663ec combine projects 2016-02-18 13:03:40 +01:00