Fix python3 binary - character mismatch in api.py

Convert between text and binary data in api.py call to urllib.request
and response from it.

In python3 sqlmapapi -c it fixes, at least
- not nice output from log/list commands
- any command that POSTs data (including new) crashing sqlmapapi
This commit is contained in:
Tomas Zellerin 2020-01-15 14:45:47 +01:00 committed by Tomas Zellerin
parent c082067902
commit 0b715f7b0e

View File

@ -713,7 +713,7 @@ def _client(url, options=None):
try:
data = None
if options is not None:
data = jsonize(options)
data = jsonize(options).encode("utf-8")
headers = {"Content-Type": "application/json"}
if DataStore.username or DataStore.password:
@ -721,7 +721,7 @@ def _client(url, options=None):
req = _urllib.request.Request(url, data, headers)
response = _urllib.request.urlopen(req)
text = response.read()
text = response.read().decode("utf-8")
except:
if options:
logger.error("Failed to load and parse %s" % url)