Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/DIRAC/Core/Utilities/MySQL.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,9 @@ def __escapeString(self, myString, connection=None):
# self.log.debug('__escape_string: Could not escape string', '"%s"' % myString)
return S_ERROR(DErrno.EMYSQL, "__escape_string: Could not escape string")

escape_string = connection.escape_string(myString.encode()).decode()
escape_string = connection.string_literal(myString.encode()).decode()
# self.log.debug('__escape_string: returns', '"%s"' % escape_string)
return S_OK(f'"{escape_string}"')
return S_OK(escape_string)
except Exception as x:
return self._except("__escape_string", x, "Could not escape string", myString)

Expand Down
5 changes: 4 additions & 1 deletion src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
)
from DIRAC.FrameworkSystem.Client.ComponentMonitoringClient import ComponentMonitoringClient

SQL_IDENTIFIER_RE = re.compile(r"^[a-zA-Z_][a-zA-Z0-9_]*$")


def _safeFloat(value):
try:
Expand Down Expand Up @@ -2114,7 +2116,8 @@ def installDatabase(self, dbName):
"""
Install requested DB in MySQL server
"""
dbName = MySQLdb.escape_string(dbName.encode()).decode()
if not SQL_IDENTIFIER_RE.match(dbName):
return S_ERROR(f"Invalid database name '{dbName}'")
if not self.mysqlRootPwd:
rootPwdPath = cfgInstallPath("Database", "RootPwd")
return S_ERROR(f"Missing {rootPwdPath} in {self.cfgFile}")
Expand Down
Loading
Loading