mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-01-23 15:54:24 +03:00
Fixes #1411
This commit is contained in:
parent
5de1825d0c
commit
ee38574449
|
@ -3979,7 +3979,7 @@ def pollProcess(process, suppress_errors=False):
|
|||
|
||||
break
|
||||
|
||||
def getSafeExString(ex):
|
||||
def getSafeExString(ex, encoding=None):
|
||||
"""
|
||||
Safe way how to get the proper exception represtation as a string
|
||||
(Note: errors to be avoided: 1) "%s" % Exception(u'\u0161') and 2) "%s" % str(Exception(u'\u0161'))
|
||||
|
@ -3992,4 +3992,4 @@ def getSafeExString(ex):
|
|||
elif getattr(ex, "msg", None):
|
||||
retVal = ex.msg
|
||||
|
||||
return getUnicode(retVal)
|
||||
return getUnicode(retVal, encoding=encoding)
|
||||
|
|
|
@ -8,9 +8,11 @@ See the file 'doc/COPYING' for copying permission
|
|||
import sqlite3
|
||||
|
||||
from extra.safe2bin.safe2bin import safechardecode
|
||||
from lib.core.common import getSafeExString
|
||||
from lib.core.common import unsafeSQLIdentificatorNaming
|
||||
from lib.core.exception import SqlmapGenericException
|
||||
from lib.core.exception import SqlmapValueException
|
||||
from lib.core.settings import UNICODE_ENCODING
|
||||
|
||||
class Replication(object):
|
||||
"""
|
||||
|
@ -49,11 +51,16 @@ class Replication(object):
|
|||
self.name = unsafeSQLIdentificatorNaming(name)
|
||||
self.columns = columns
|
||||
if create:
|
||||
self.execute('DROP TABLE IF EXISTS "%s"' % self.name)
|
||||
if not typeless:
|
||||
self.execute('CREATE TABLE "%s" (%s)' % (self.name, ','.join('"%s" %s' % (unsafeSQLIdentificatorNaming(colname), coltype) for colname, coltype in self.columns)))
|
||||
else:
|
||||
self.execute('CREATE TABLE "%s" (%s)' % (self.name, ','.join('"%s"' % unsafeSQLIdentificatorNaming(colname) for colname in self.columns)))
|
||||
try:
|
||||
self.execute('DROP TABLE IF EXISTS "%s"' % self.name)
|
||||
if not typeless:
|
||||
self.execute('CREATE TABLE "%s" (%s)' % (self.name, ','.join('"%s" %s' % (unsafeSQLIdentificatorNaming(colname), coltype) for colname, coltype in self.columns)))
|
||||
else:
|
||||
self.execute('CREATE TABLE "%s" (%s)' % (self.name, ','.join('"%s"' % unsafeSQLIdentificatorNaming(colname) for colname in self.columns)))
|
||||
except Exception, ex:
|
||||
errMsg = "problem occurred ('%s') while initializing the sqlite database " % getSafeExString(ex, UNICODE_ENCODING)
|
||||
errMsg += "located at '%s'" % self.parent.dbpath
|
||||
raise SqlmapGenericException(errMsg)
|
||||
|
||||
def insert(self, values):
|
||||
"""
|
||||
|
@ -70,7 +77,7 @@ class Replication(object):
|
|||
try:
|
||||
self.parent.cursor.execute(sql, parameters)
|
||||
except sqlite3.OperationalError, ex:
|
||||
errMsg = "problem occurred ('%s') while accessing sqlite database " % unicode(ex)
|
||||
errMsg = "problem occurred ('%s') while accessing sqlite database " % getSafeExString(ex, UNICODE_ENCODING)
|
||||
errMsg += "located at '%s'. Please make sure that " % self.parent.dbpath
|
||||
errMsg += "it's not used by some other program"
|
||||
raise SqlmapGenericException(errMsg)
|
||||
|
|
Loading…
Reference in New Issue
Block a user