mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-01-24 08:14:24 +03:00
Support for dotted identificator names
This commit is contained in:
parent
52431402dd
commit
ffbbb10abb
|
@ -2711,23 +2711,22 @@ def safeSQLIdentificatorNaming(name, isTable=False):
|
||||||
retVal = name
|
retVal = name
|
||||||
|
|
||||||
if isinstance(name, basestring):
|
if isinstance(name, basestring):
|
||||||
name = getUnicode(name)
|
retVal = getUnicode(name)
|
||||||
|
_ = isTable and Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE)
|
||||||
|
|
||||||
if isTable and Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE) and '.' not in name:
|
if _:
|
||||||
name = "%s.%s" % (DEFAULT_MSSQL_SCHEMA, name)
|
retVal = re.sub(r"(?i)\A%s\." % DEFAULT_MSSQL_SCHEMA, "", retVal)
|
||||||
|
|
||||||
parts = name.split('.')
|
if not re.match(r"\A[A-Za-z0-9_@\$]+\Z", retVal): # Reference: http://stackoverflow.com/questions/954884/what-special-characters-are-allowed-in-t-sql-column-retVal
|
||||||
|
|
||||||
for i in xrange(len(parts)):
|
|
||||||
if not re.match(r"\A[A-Za-z0-9_@\$]+\Z", parts[i]): # Reference: http://stackoverflow.com/questions/954884/what-special-characters-are-allowed-in-t-sql-column-name
|
|
||||||
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.ACCESS):
|
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.ACCESS):
|
||||||
parts[i] = "`%s`" % parts[i].strip("`")
|
retVal = "`%s`" % retVal.strip("`")
|
||||||
elif Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.PGSQL, DBMS.DB2):
|
elif Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.PGSQL, DBMS.DB2):
|
||||||
parts[i] = "\"%s\"" % parts[i].strip("\"")
|
retVal = "\"%s\"" % retVal.strip("\"")
|
||||||
elif Backend.getIdentifiedDbms() in (DBMS.MSSQL,):
|
elif Backend.getIdentifiedDbms() in (DBMS.MSSQL,):
|
||||||
parts[i] = "[%s]" % parts[i].strip("[]")
|
retVal = "[%s]" % retVal.strip("[]")
|
||||||
|
|
||||||
retVal = ".".join(parts)
|
if _ and DEFAULT_MSSQL_SCHEMA not in retVal:
|
||||||
|
retVal = "%s.%s" % (DEFAULT_MSSQL_SCHEMA, retVal)
|
||||||
|
|
||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user