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

Method escape

plugins/dbms/informix/syntax.py:17–42  ·  view source on GitHub ↗

>>> from lib.core.common import Backend >>> Backend.setVersion('12.10') ['12.10'] >>> Syntax.escape("SELECT 'abcdefgh' FROM foobar") == "SELECT CHR(97)||CHR(98)||CHR(99)||CHR(100)||CHR(101)||CHR(102)||CHR(103)||CHR(104) FROM foobar" True

(expression, quote=True)

Source from the content-addressed store, hash-verified

15class Syntax(GenericSyntax):
16 @staticmethod
17 def escape(expression, quote=True):
18 """
19 >>> from lib.core.common import Backend
20 >>> Backend.setVersion('12.10')
21 ['12.10']
22 >>> Syntax.escape("SELECT 'abcdefgh' FROM foobar") == "SELECT CHR(97)||CHR(98)||CHR(99)||CHR(100)||CHR(101)||CHR(102)||CHR(103)||CHR(104) FROM foobar"
23 True
24 """
25
26 def escaper(value):
27 return "||".join("CHR(%d)" % _ for _ in getOrds(value))
28
29 retVal = expression
30
31 if isDBMSVersionAtLeast("11.70"):
32 excluded = {}
33 for _ in re.findall(r"DBINFO\([^)]+\)", expression):
34 excluded[_] = randomStr()
35 expression = expression.replace(_, excluded[_])
36
37 retVal = Syntax._escape(expression, quote, escaper)
38
39 for _ in excluded.items():
40 retVal = retVal.replace(_[1], _[0])
41
42 return retVal

Callers

nothing calls this directly

Calls 5

isDBMSVersionAtLeastFunction · 0.90
randomStrFunction · 0.90
_escapeMethod · 0.80
itemsMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected