@@ -15,59 +15,63 @@ class Syntax(GenericSyntax):
1515 def __init__ (self ):
1616 GenericSyntax .__init__ (self )
1717
18+ # As ASCII_CHAR is only available from v2.1 we'll need to adapt this one to use the
19+ # commented-out part only if detected version>=2.1
20+ # Reference: wiki.firebirdsql.org/wiki/index.php?page=ASCII_CHAR
21+
1822 @staticmethod
1923 def unescape (expression , quote = True ):
20- if quote :
21- while True :
22- index = expression .find ("'" )
23- if index == - 1 :
24- break
24+ # if quote:
25+ # while True:
26+ # index = expression.find("'")
27+ # if index == -1:
28+ # break
2529
26- firstIndex = index + 1
27- index = expression [firstIndex :].find ("'" )
30+ # firstIndex = index + 1
31+ # index = expression[firstIndex:].find("'")
2832
29- if index == - 1 :
30- raise sqlmapSyntaxException , "Unenclosed ' in '%s'" % expression
33+ # if index == -1:
34+ # raise sqlmapSyntaxException, "Unenclosed ' in '%s'" % expression
3135
32- lastIndex = firstIndex + index
33- old = "'%s'" % expression [firstIndex :lastIndex ]
34- unescaped = ""
36+ # lastIndex = firstIndex + index
37+ # old = "'%s'" % expression[firstIndex:lastIndex]
38+ # unescaped = ""
3539
36- for i in range (firstIndex , lastIndex ):
37- unescaped += "ASCII_CHAR(%d)" % (ord (expression [i ]))
38- if i < lastIndex - 1 :
39- unescaped += "||"
40+ # for i in range(firstIndex, lastIndex):
41+ # unescaped += "ASCII_CHAR(%d)" % (ord(expression[i]))
42+ # if i < lastIndex - 1:
43+ # unescaped += "||"
4044
41- expression = expression .replace (old , unescaped )
42- else :
43- unescaped = "" .join ("ASCII_CHAR(%d)||" % ord (c ) for c in expression )
44- if unescaped [- 1 ] == "||" :
45- unescaped = unescaped [:- 1 ]
45+ # expression = expression.replace(old, unescaped)
46+ # else:
47+ # unescaped = "".join("ASCII_CHAR(%d)||" % ord(c) for c in expression)
48+ # if unescaped[-1] == "||":
49+ # unescaped = unescaped[:-1]
4650
47- expression = unescaped
51+ # expression = unescaped
4852
4953 return expression
5054
5155 @staticmethod
5256 def escape (expression ):
53- while True :
54- index = expression .find ("ASCII_CHAR(" )
55- if index == - 1 :
56- break
57+ # while True:
58+ # index = expression.find("ASCII_CHAR(")
59+ # if index == -1:
60+ # break
5761
58- firstIndex = index
59- index = expression [firstIndex :].find (")" )
62+ # firstIndex = index
63+ # index = expression[firstIndex:].find(")")
6064
61- if index == - 1 :
62- raise sqlmapSyntaxException , "Unenclosed ) in '%s'" % expression
65+ # if index == -1:
66+ # raise sqlmapSyntaxException, "Unenclosed ) in '%s'" % expression
6367
64- lastIndex = firstIndex + index + 1
65- old = expression [firstIndex :lastIndex ]
66- oldUpper = old .upper ()
67- oldUpper = oldUpper .lstrip ("ASCII_CHAR(" ).rstrip (")" )
68- oldUpper = oldUpper .split ("||" )
68+ # lastIndex = firstIndex + index + 1
69+ # old = expression[firstIndex:lastIndex]
70+ # oldUpper = old.upper()
71+ # oldUpper = oldUpper.lstrip("ASCII_CHAR(").rstrip(")")
72+ # oldUpper = oldUpper.split("||")
6973
70- escaped = "'%s'" % "" .join ([chr (int (char )) for char in oldUpper ])
71- expression = expression .replace (old , escaped ).replace ("'||'" , "" )
74+ # escaped = "'%s'" % "".join([chr(int(char)) for char in oldUpper])
75+ # expression = expression.replace(old, escaped).replace("'||'", "")
7276
7377 return expression
0 commit comments