mirror of
https://github.com/9001/copyparty.git
synced 2025-08-22 19:32:20 -06:00
add pebkac hints
This commit is contained in:
parent
2579dc64ce
commit
6249bd4163
|
@ -10,7 +10,6 @@ import json
|
||||||
import string
|
import string
|
||||||
import socket
|
import socket
|
||||||
import ctypes
|
import ctypes
|
||||||
import traceback
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import calendar
|
import calendar
|
||||||
|
|
||||||
|
@ -50,6 +49,7 @@ class HttpCli(object):
|
||||||
self.tls = hasattr(self.s, "cipher")
|
self.tls = hasattr(self.s, "cipher")
|
||||||
|
|
||||||
self.bufsz = 1024 * 32
|
self.bufsz = 1024 * 32
|
||||||
|
self.hint = None
|
||||||
self.absolute_urls = False
|
self.absolute_urls = False
|
||||||
self.out_headers = {"Access-Control-Allow-Origin": "*"}
|
self.out_headers = {"Access-Control-Allow-Origin": "*"}
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ class HttpCli(object):
|
||||||
"""returns true if connection can be reused"""
|
"""returns true if connection can be reused"""
|
||||||
self.keepalive = False
|
self.keepalive = False
|
||||||
self.headers = {}
|
self.headers = {}
|
||||||
|
self.hint = None
|
||||||
try:
|
try:
|
||||||
headerlines = read_header(self.sr)
|
headerlines = read_header(self.sr)
|
||||||
if not headerlines:
|
if not headerlines:
|
||||||
|
@ -130,6 +131,9 @@ class HttpCli(object):
|
||||||
if v is not None:
|
if v is not None:
|
||||||
self.log("[H] {}: \033[33m[{}]".format(k, v), 6)
|
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
|
# split req into vpath + uparam
|
||||||
uparam = {}
|
uparam = {}
|
||||||
if "?" not in self.req:
|
if "?" not in self.req:
|
||||||
|
@ -199,6 +203,9 @@ class HttpCli(object):
|
||||||
|
|
||||||
self.log("{}\033[0m, {}".format(str(ex), self.vpath), 3)
|
self.log("{}\033[0m, {}".format(str(ex), self.vpath), 3)
|
||||||
msg = "<pre>{}\r\nURL: {}\r\n".format(str(ex), self.vpath)
|
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)
|
self.reply(msg.encode("utf-8", "replace"), status=ex.code)
|
||||||
return self.keepalive
|
return self.keepalive
|
||||||
except Pebkac:
|
except Pebkac:
|
||||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import print_function, unicode_literals
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import time
|
import time
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
|
|
|
@ -653,7 +653,7 @@ class Up2k(object):
|
||||||
try:
|
try:
|
||||||
parser = MParser(parser)
|
parser = MParser(parser)
|
||||||
except:
|
except:
|
||||||
self.log("invalid argument: " + parser, 1)
|
self.log("invalid argument (could not find program): " + parser, 1)
|
||||||
return
|
return
|
||||||
|
|
||||||
for tag in entags:
|
for tag in entags:
|
||||||
|
|
Loading…
Reference in a new issue