sqlmap/plugins/generic/syntax.py

39 lines
931 B
Python
Raw Normal View History

2019-05-08 13:47:52 +03:00
#!/usr/bin/env python
"""
2019-01-05 23:38:52 +03:00
Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)
2017-10-11 15:50:46 +03:00
See the file 'LICENSE' for copying permission
"""
import re
from lib.core.exception import SqlmapUndefinedMethod
2019-05-29 17:42:04 +03:00
class Syntax(object):
"""
This class defines generic syntax functionalities for plugins.
"""
def __init__(self):
pass
@staticmethod
def _escape(expression, quote=True, escaper=None):
retVal = expression
if quote:
2017-04-14 14:08:51 +03:00
for item in re.findall(r"'[^']*'+", expression):
_ = item[1:-1]
if _:
retVal = retVal.replace(item, escaper(_))
else:
retVal = escaper(expression)
return retVal
@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"
raise SqlmapUndefinedMethod(errMsg)