2013-02-14 15:32:17 +04:00
|
|
|
#!/usr/bin/env python
|
2010-03-23 01:57:57 +03:00
|
|
|
|
|
|
|
"""
|
2017-01-02 16:19:18 +03:00
|
|
|
Copyright (c) 2006-2017 sqlmap developers (http://sqlmap.org/)
|
2010-10-15 03:18:29 +04:00
|
|
|
See the file 'doc/COPYING' for copying permission
|
2010-03-23 01:57:57 +03:00
|
|
|
"""
|
|
|
|
|
2013-01-20 16:45:58 +04:00
|
|
|
import re
|
|
|
|
|
2012-12-06 17:14:19 +04:00
|
|
|
from lib.core.exception import SqlmapUndefinedMethod
|
2010-03-23 01:57:57 +03:00
|
|
|
|
|
|
|
class Syntax:
|
|
|
|
"""
|
|
|
|
This class defines generic syntax functionalities for plugins.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
pass
|
|
|
|
|
2013-01-20 16:45:58 +04:00
|
|
|
@staticmethod
|
|
|
|
def _escape(expression, quote=True, escaper=None):
|
|
|
|
retVal = expression
|
|
|
|
|
|
|
|
if quote:
|
2013-01-21 14:21:41 +04:00
|
|
|
for item in re.findall(r"'[^']*'+", expression, re.S):
|
2013-06-11 14:56:20 +04:00
|
|
|
_ = item[1:-1]
|
|
|
|
if _:
|
|
|
|
retVal = retVal.replace(item, escaper(_))
|
2013-01-20 16:45:58 +04:00
|
|
|
else:
|
|
|
|
retVal = escaper(expression)
|
|
|
|
|
|
|
|
return retVal
|
|
|
|
|
2010-03-23 01:57:57 +03:00
|
|
|
@staticmethod
|
2013-01-18 19:10:34 +04:00
|
|
|
def escape(expression, quote=True):
|
2011-04-30 17:20:05 +04:00
|
|
|
errMsg = "'escape' method must be defined "
|
2013-01-18 18:40:37 +04:00
|
|
|
errMsg += "inside the specific DBMS plugin"
|
2013-01-04 02:20:55 +04:00
|
|
|
raise SqlmapUndefinedMethod(errMsg)
|