Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1cfe370

Browse files
committed
More refactoring for #4077
1 parent 3776f2e commit 1cfe370

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

lib/core/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def getBytes(value, encoding=None, errors="strict", unsafe=True):
238238
retVal = value
239239

240240
if encoding is None:
241-
encoding = conf.encoding or UNICODE_ENCODING
241+
encoding = conf.get("encoding") or UNICODE_ENCODING
242242

243243
try:
244244
codecs.lookup(encoding)

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.4.1.24"
21+
VERSION = "1.4.1.25"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/utils/api.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
from lib.core.convert import dejsonize
3030
from lib.core.convert import encodeBase64
3131
from lib.core.convert import encodeHex
32+
from lib.core.convert import getBytes
33+
from lib.core.convert import getText
3234
from lib.core.convert import jsonize
3335
from lib.core.data import conf
3436
from lib.core.data import kb
@@ -711,17 +713,19 @@ def server(host=RESTAPI_DEFAULT_ADDRESS, port=RESTAPI_DEFAULT_PORT, adapter=REST
711713
def _client(url, options=None):
712714
logger.debug("Calling '%s'" % url)
713715
try:
714-
data = None
715-
if options is not None:
716-
data = jsonize(options).encode("utf-8")
717716
headers = {"Content-Type": "application/json"}
718717

718+
if options is not None:
719+
data = getBytes(jsonize(options))
720+
else:
721+
data = None
722+
719723
if DataStore.username or DataStore.password:
720724
headers["Authorization"] = "Basic %s" % encodeBase64("%s:%s" % (DataStore.username or "", DataStore.password or ""), binary=False)
721725

722726
req = _urllib.request.Request(url, data, headers)
723727
response = _urllib.request.urlopen(req)
724-
text = response.read().decode("utf-8")
728+
text = getText(response.read())
725729
except:
726730
if options:
727731
logger.error("Failed to load and parse %s" % url)

0 commit comments

Comments
 (0)