From 15d9c8f9ede7e359fbe6d5f7555d3bd9e4faa2c9 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Mon, 20 Feb 2023 14:44:56 +0100 Subject: [PATCH] Updating bottlepy to the latest revision --- lib/core/settings.py | 2 +- thirdparty/bottle/bottle.py | 80 ++++++++++++++++--------------------- 2 files changed, 35 insertions(+), 47 deletions(-) diff --git a/lib/core/settings.py b/lib/core/settings.py index a871a8921..71e4a85c5 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -20,7 +20,7 @@ from thirdparty import six from thirdparty.six import unichr as _unichr # sqlmap version (...) -VERSION = "1.7.2.10" +VERSION = "1.7.2.11" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) diff --git a/thirdparty/bottle/bottle.py b/thirdparty/bottle/bottle.py index 48aefbb69..916e2607d 100644 --- a/thirdparty/bottle/bottle.py +++ b/thirdparty/bottle/bottle.py @@ -69,12 +69,12 @@ if __name__ == '__main__': # Imports and Python 2/3 unification ########################################## ############################################################################### -import base64, calendar, cgi, email.utils, functools, hmac, imp, itertools,\ +import base64, calendar, cgi, email.utils, functools, hmac, itertools,\ mimetypes, os, re, tempfile, threading, time, warnings, weakref, hashlib from types import FunctionType from datetime import date as datedate, datetime, timedelta -from tempfile import TemporaryFile +from tempfile import NamedTemporaryFile from traceback import format_exc, print_exc from unicodedata import normalize @@ -83,34 +83,6 @@ try: except ImportError: from json import dumps as json_dumps, loads as json_lds -# inspect.getargspec was removed in Python 3.6, use -# Signature-based version where we can (Python 3.3+) -try: - from inspect import signature - def getargspec(func): - params = signature(func).parameters - args, varargs, keywords, defaults = [], None, None, [] - for name, param in params.items(): - if param.kind == param.VAR_POSITIONAL: - varargs = name - elif param.kind == param.VAR_KEYWORD: - keywords = name - else: - args.append(name) - if param.default is not param.empty: - defaults.append(param.default) - return (args, varargs, keywords, tuple(defaults) or None) -except ImportError: - try: - from inspect import getfullargspec - def getargspec(func): - spec = getfullargspec(func) - kwargs = makelist(spec[0]) + makelist(spec.kwonlyargs) - return kwargs, spec[1], spec[2], spec[3] - except ImportError: - from inspect import getargspec - - py = sys.version_info py3k = py.major > 2 @@ -123,9 +95,17 @@ if py3k: urlunquote = functools.partial(urlunquote, encoding='latin1') from http.cookies import SimpleCookie, Morsel, CookieError from collections.abc import MutableMapping as DictMixin + from types import ModuleType as new_module import pickle from io import BytesIO import configparser + # getfullargspec was deprecated in 3.5 and un-deprecated in 3.6 + # getargspec was deprecated in 3.0 and removed in 3.11 + from inspect import getfullargspec + def getargspec(func): + spec = getfullargspec(func) + kwargs = makelist(spec[0]) + makelist(spec.kwonlyargs) + return kwargs, spec[1], spec[2], spec[3] basestring = str unicode = str @@ -143,9 +123,12 @@ else: # 2.x from Cookie import SimpleCookie, Morsel, CookieError from itertools import imap import cPickle as pickle + from imp import new_module from StringIO import StringIO as BytesIO import ConfigParser as configparser from collections import MutableMapping as DictMixin + from inspect import getargspec + unicode = unicode json_loads = json_lds exec(compile('def _raise(*a): raise a[0], a[1], a[2]', '', 'exec')) @@ -256,6 +239,7 @@ class lazy_attribute(object): setattr(cls, self.__name__, value) return value + ############################################################################### # Exceptions and Events ####################################################### ############################################################################### @@ -1353,7 +1337,7 @@ class BaseRequest(object): body.write(part) body_size += len(part) if not is_temp_file and body_size > self.MEMFILE_MAX: - body, tmp = TemporaryFile(mode='w+b'), body + body, tmp = NamedTemporaryFile(mode='w+b'), body body.write(tmp.getvalue()) del tmp is_temp_file = True @@ -2010,6 +1994,7 @@ class JSONPlugin(object): dumps = self.json_dumps if not self.json_dumps: return callback + @functools.wraps(callback) def wrapper(*a, **ka): try: rv = callback(*a, **ka) @@ -2057,7 +2042,7 @@ class _ImportRedirect(object): """ Create a virtual package that redirects imports (see PEP 302). """ self.name = name self.impmask = impmask - self.module = sys.modules.setdefault(name, imp.new_module(name)) + self.module = sys.modules.setdefault(name, new_module(name)) self.module.__dict__.update({ '__file__': __file__, '__path__': [], @@ -2066,10 +2051,15 @@ class _ImportRedirect(object): }) sys.meta_path.append(self) + def find_spec(self, fullname, path, target=None): + if '.' not in fullname: return + if fullname.rsplit('.', 1)[0] != self.name: return + from importlib.util import spec_from_loader + return spec_from_loader(fullname, self) + def find_module(self, fullname, path=None): if '.' not in fullname: return - packname = fullname.rsplit('.', 1)[0] - if packname != self.name: return + if fullname.rsplit('.', 1)[0] != self.name: return return self def load_module(self, fullname): @@ -2825,18 +2815,15 @@ def redirect(url, code=None): raise res -def _file_iter_range(fp, offset, bytes, maxread=1024 * 1024, close=False): - """ Yield chunks from a range in a file, optionally closing it at the end. - No chunk is bigger than maxread. """ +def _rangeiter(fp, offset, limit, bufsize=1024 * 1024): + """ Yield chunks from a range in a file. """ fp.seek(offset) - while bytes > 0: - part = fp.read(min(bytes, maxread)) + while limit > 0: + part = fp.read(min(limit, bufsize)) if not part: break - bytes -= len(part) + limit -= len(part) yield part - if close: - fp.close() def static_file(filename, root, @@ -2940,9 +2927,10 @@ def static_file(filename, root, if not ranges: return HTTPError(416, "Requested Range Not Satisfiable") offset, end = ranges[0] + rlen = end - offset headers["Content-Range"] = "bytes %d-%d/%d" % (offset, end - 1, clen) - headers["Content-Length"] = str(end - offset) - if body: body = _file_iter_range(body, offset, end - offset, close=True) + headers["Content-Length"] = str(rlen) + if body: body = _closeiter(_rangeiter(body, offset, rlen), body.close) return HTTPResponse(body, status=206, **headers) return HTTPResponse(body, **headers) @@ -3359,7 +3347,7 @@ class MeinheldServer(ServerAdapter): class FapwsServer(ServerAdapter): - """ Extremely fast webserver using libev. See http://www.fapws.org/ """ + """ Extremely fast webserver using libev. See https://github.com/william-os4y/fapws3 """ def run(self, handler): # pragma: no cover depr(0, 13, "fapws3 is not maintained and support will be dropped.") @@ -4276,7 +4264,7 @@ def view(tpl_name, **defaults): tplvars.update(result) return template(tpl_name, **tplvars) elif result is None: - return template(tpl_name, defaults) + return template(tpl_name, **defaults) return result return wrapper