diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-06-04 19:09:38 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-06-04 19:09:38 +1200 |
commit | ae9f470d2b6e44fb87270b41a7694ed3b209da71 (patch) | |
tree | 0777260d31afc1ef7b96cd439696c69044e73672 /libpathod/pathod.py | |
parent | c5992b8d23e4b312e7ea8a4e74ef23c095c4164f (diff) | |
download | mitmproxy-ae9f470d2b6e44fb87270b41a7694ed3b209da71.tar.gz mitmproxy-ae9f470d2b6e44fb87270b41a7694ed3b209da71.tar.bz2 mitmproxy-ae9f470d2b6e44fb87270b41a7694ed3b209da71.zip |
Craft anchor is now specified as a regex
Unifies this with anchor points.
Diffstat (limited to 'libpathod/pathod.py')
-rw-r--r-- | libpathod/pathod.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libpathod/pathod.py b/libpathod/pathod.py index b8df2eff..839b5406 100644 --- a/libpathod/pathod.py +++ b/libpathod/pathod.py @@ -4,6 +4,8 @@ import os import sys import threading import urllib +import re + from netlib import tcp, http, wsgi, certutils, websockets from . import version, app, language, utils, log @@ -15,6 +17,7 @@ DEFAULT_CERT_DOMAIN = "pathod.net" CONFDIR = "~/.mitmproxy" CERTSTORE_BASENAME = "mitmproxy" CA_CERT_NAME = "mitmproxy-ca.pem" +DEFAULT_ANCHOR = r"/p/?" logger = logging.getLogger('pathod') @@ -246,10 +249,9 @@ class PathodHandler(tcp.BaseHandler): nexthandler, retlog["response"] = self.serve_crafted(i[1]) return nexthandler, retlog - if not self.server.nocraft and utils.matchpath( - path, - self.server.craftanchor): - spec = urllib.unquote(path)[len(self.server.craftanchor) + 1:] + m = utils.MemBool() + if m(self.server.craftanchor.match(path)): + spec = urllib.unquote(path)[len(m.v.group()):] websocket_key = websockets.check_client_handshake(headers) self.settings.websocket_key = websocket_key if websocket_key and not spec: @@ -323,7 +325,7 @@ class Pathod(tcp.TCPServer): addr, ssl=False, ssloptions=None, - craftanchor="/p", + craftanchor=re.compile(DEFAULT_ANCHOR), staticdir=None, anchors=(), sizelimit=None, @@ -380,6 +382,8 @@ class Pathod(tcp.TCPServer): """ A policy check that verifies the request size is withing limits. """ + if self.nocraft: + return "Crafting disabled.", None try: req = req.resolve(settings) l = req.maximum_length(settings) |