Skip to content

Commit cceb531

Browse files
committed
Fixes #4869
1 parent 8a57002 commit cceb531

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

lib/core/common.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,19 @@ def cleanQuery(query):
14311431

14321432
return retVal
14331433

1434+
def cleanReplaceUnicode(value):
1435+
"""
1436+
Cleans unicode for proper encode/decode
1437+
1438+
>>> cleanReplaceUnicode(['a', 'b'])
1439+
['a', 'b']
1440+
"""
1441+
1442+
def clean(value):
1443+
return value.encode(UNICODE_ENCODING, errors="replace").decode(UNICODE_ENCODING) if isinstance(value, six.text_type) else value
1444+
1445+
return applyFunctionRecursively(value, clean)
1446+
14341447
def setPaths(rootPath):
14351448
"""
14361449
Sets absolute paths for project directories and files

lib/core/replication.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import sqlite3
99

10+
from lib.core.common import cleanReplaceUnicode
1011
from lib.core.common import getSafeExString
1112
from lib.core.common import unsafeSQLIdentificatorNaming
1213
from lib.core.exception import SqlmapConnectionException
@@ -81,7 +82,10 @@ def insert(self, values):
8182

8283
def execute(self, sql, parameters=None):
8384
try:
84-
self.parent.cursor.execute(sql, parameters or [])
85+
try:
86+
self.parent.cursor.execute(sql, parameters or [])
87+
except UnicodeError:
88+
self.parent.cursor.execute(sql, cleanReplaceUnicode(parameters or []))
8589
except sqlite3.OperationalError as ex:
8690
errMsg = "problem occurred ('%s') while accessing sqlite database " % getSafeExString(ex, UNICODE_ENCODING)
8791
errMsg += "located at '%s'. Please make sure that " % self.parent.dbpath

lib/core/settings.py

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

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

0 commit comments

Comments
 (0)