add pebkac hints

This commit is contained in:
ed 2021-06-22 17:18:34 +02:00
parent 2579dc64ce
commit 6249bd4163
3 changed files with 9 additions and 3 deletions

View file

@ -10,7 +10,6 @@ import json
import string
import socket
import ctypes
import traceback
from datetime import datetime
import calendar
@ -50,6 +49,7 @@ class HttpCli(object):
self.tls = hasattr(self.s, "cipher")
self.bufsz = 1024 * 32
self.hint = None
self.absolute_urls = False
self.out_headers = {"Access-Control-Allow-Origin": "*"}
@ -72,6 +72,7 @@ class HttpCli(object):
"""returns true if connection can be reused"""
self.keepalive = False
self.headers = {}
self.hint = None
try:
headerlines = read_header(self.sr)
if not headerlines:
@ -130,6 +131,9 @@ class HttpCli(object):
if v is not None:
self.log("[H] {}: \033[33m[{}]".format(k, v), 6)
if "&" in self.req and "?" not in self.req:
self.hint = "did you mean '?' instead of '&'"
# split req into vpath + uparam
uparam = {}
if "?" not in self.req:
@ -199,6 +203,9 @@ class HttpCli(object):
self.log("{}\033[0m, {}".format(str(ex), self.vpath), 3)
msg = "<pre>{}\r\nURL: {}\r\n".format(str(ex), self.vpath)
if self.hint:
msg += "hint: {}\r\n".format(self.hint)
self.reply(msg.encode("utf-8", "replace"), status=ex.code)
return self.keepalive
except Pebkac:

View file

@ -3,7 +3,6 @@ from __future__ import print_function, unicode_literals
import re
import os
import sys
import time
import socket

View file

@ -653,7 +653,7 @@ class Up2k(object):
try:
parser = MParser(parser)
except:
self.log("invalid argument: " + parser, 1)
self.log("invalid argument (could not find program): " + parser, 1)
return
for tag in entags: