mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-12-04 12:40:06 +00:00
fix craft anchor
The go-button in the app was broken due to an invalid string representation of the regex. A plain string used as URL prefix simplifies this drastically.
This commit is contained in:
parent
0bc8fa1d0d
commit
22811c45dd
@ -20,7 +20,7 @@ DEFAULT_CERT_DOMAIN = "pathod.net"
|
|||||||
CONFDIR = "~/.mitmproxy"
|
CONFDIR = "~/.mitmproxy"
|
||||||
CERTSTORE_BASENAME = "mitmproxy"
|
CERTSTORE_BASENAME = "mitmproxy"
|
||||||
CA_CERT_NAME = "mitmproxy-ca.pem"
|
CA_CERT_NAME = "mitmproxy-ca.pem"
|
||||||
DEFAULT_ANCHOR = r"/p/?"
|
DEFAULT_CRAFT_ANCHOR = "/p/"
|
||||||
|
|
||||||
logger = logging.getLogger('pathod')
|
logger = logging.getLogger('pathod')
|
||||||
|
|
||||||
@ -293,8 +293,9 @@ class PathodHandler(tcp.BaseHandler):
|
|||||||
anchor_gen = i[1]
|
anchor_gen = i[1]
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if m(self.server.craftanchor.match(path)):
|
print(self.server.craftanchor)
|
||||||
spec = urllib.unquote(path)[len(m.v.group()):]
|
if m(path.startswith(self.server.craftanchor)):
|
||||||
|
spec = urllib.unquote(path)[len(self.server.craftanchor):]
|
||||||
if spec:
|
if spec:
|
||||||
try:
|
try:
|
||||||
anchor_gen = language.parse_pathod(spec)
|
anchor_gen = language.parse_pathod(spec)
|
||||||
@ -373,7 +374,7 @@ class Pathod(tcp.TCPServer):
|
|||||||
addr,
|
addr,
|
||||||
ssl=False,
|
ssl=False,
|
||||||
ssloptions=None,
|
ssloptions=None,
|
||||||
craftanchor=re.compile(DEFAULT_ANCHOR),
|
craftanchor=DEFAULT_CRAFT_ANCHOR,
|
||||||
staticdir=None,
|
staticdir=None,
|
||||||
anchors=(),
|
anchors=(),
|
||||||
sizelimit=None,
|
sizelimit=None,
|
||||||
@ -393,7 +394,7 @@ class Pathod(tcp.TCPServer):
|
|||||||
addr: (address, port) tuple. If port is 0, a free port will be
|
addr: (address, port) tuple. If port is 0, a free port will be
|
||||||
automatically chosen.
|
automatically chosen.
|
||||||
ssloptions: an SSLOptions object.
|
ssloptions: an SSLOptions object.
|
||||||
craftanchor: string specifying the path under which to anchor
|
craftanchor: URL prefix specifying the path under which to anchor
|
||||||
response generation.
|
response generation.
|
||||||
staticdir: path to a directory of static resources, or None.
|
staticdir: path to a directory of static resources, or None.
|
||||||
anchors: List of (regex object, language.Request object) tuples, or
|
anchors: List of (regex object, language.Request object) tuples, or
|
||||||
|
@ -45,11 +45,11 @@ def args_pathod(argv, stdout=sys.stdout, stderr=sys.stderr):
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-c", dest='craftanchor', default=pathod.DEFAULT_ANCHOR, type=str,
|
"-c", dest='craftanchor', default=pathod.DEFAULT_CRAFT_ANCHOR, type=str,
|
||||||
help="""
|
help="""
|
||||||
Regular expression specifying anchor point for URL crafting
|
URL path specifying prefix for URL crafting
|
||||||
commands. (%s)
|
commands. (%s)
|
||||||
"""%pathod.DEFAULT_ANCHOR
|
"""%pathod.DEFAULT_CRAFT_ANCHOR
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--confdir",
|
"--confdir",
|
||||||
@ -203,13 +203,6 @@ def args_pathod(argv, stdout=sys.stdout, stderr=sys.stderr):
|
|||||||
return parser.error(v)
|
return parser.error(v)
|
||||||
args.sizelimit = sizelimit
|
args.sizelimit = sizelimit
|
||||||
|
|
||||||
try:
|
|
||||||
args.craftanchor = re.compile(args.craftanchor)
|
|
||||||
except re.error:
|
|
||||||
return parser.error(
|
|
||||||
"Invalid regex in craft anchor: %s" % args.craftanchor
|
|
||||||
)
|
|
||||||
|
|
||||||
anchors = []
|
anchors = []
|
||||||
for patt, spec in args.anchors:
|
for patt, spec in args.anchors:
|
||||||
if os.path.isfile(spec):
|
if os.path.isfile(spec):
|
||||||
|
Loading…
Reference in New Issue
Block a user