MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / getSafeExString

Function getSafeExString

lib/core/common.py:5484–5511  ·  view source on GitHub ↗

Safe way how to get the proper exception represtation as a string >>> getSafeExString(SqlmapBaseException('foobar')) == 'foobar' True >>> getSafeExString(OSError(0, 'foobar')) == 'OSError: foobar' True

(ex, encoding=None)

Source from the content-addressed store, hash-verified

5482 yield target
5483
5484def getSafeExString(ex, encoding=None):
5485 """
5486 Safe way how to get the proper exception represtation as a string
5487
5488 >>> getSafeExString(SqlmapBaseException('foobar')) == 'foobar'
5489 True
5490 >>> getSafeExString(OSError(0, 'foobar')) == 'OSError: foobar'
5491 True
5492 """
5493
5494 retVal = None
5495
5496 if getattr(ex, "message", None):
5497 retVal = ex.message
5498 elif getattr(ex, "msg", None):
5499 retVal = ex.msg
5500 elif getattr(ex, "args", None):
5501 for candidate in ex.args[::-1]:
5502 if isinstance(candidate, six.string_types):
5503 retVal = candidate
5504 break
5505
5506 if retVal is None:
5507 retVal = str(ex)
5508 elif not isinstance(ex, SqlmapBaseException):
5509 retVal = "%s: %s" % (type(ex).__name__, retVal)
5510
5511 return getUnicode(retVal or "", encoding=encoding).strip()
5512
5513def safeVariableNaming(value):
5514 """

Callers 15

mainFunction · 0.90
_bruteProcessVariantAFunction · 0.90
_bruteProcessVariantBFunction · 0.90
dictionaryAttackFunction · 0.90
_export_configMethod · 0.90
_import_configMethod · 0.90
_show_consoleMethod · 0.90
runTuiFunction · 0.90
pivotDumpTableFunction · 0.90
crawlThreadFunction · 0.90
crawlFunction · 0.90
executeMethod · 0.90

Calls 1

getUnicodeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…