fix(server): Correctly resolve database name for URI connection strings

URI-connection strings would incorrectly parse the database name when using additional options as part of the string (i.e. "ESXLegacy?charset=utf8mb4").
Correctly check for these options and match the string accordingly.

Also just better pattern matching in general.
This commit is contained in:
Linden
2021-10-23 11:58:18 +11:00
committed by GitHub
parent 565c5d0e35
commit ebae4354ce
+6 -3
View File
@@ -2,9 +2,12 @@ local function DATABASE()
local connectionString = GetConvar('mysql_connection_string', '');
if connectionString == '' then
error(connectionString..'\n^1Unable to start Multicharacter - unable to determine database from mysql_connection_string^0', 0)
elseif string.match(connectionString, 'mysql://') then
connectionString = string.sub(connectionString, string.find(connectionString, "/[^/]*$")+1)
return connectionString
elseif connectionString:find('mysql://') then
if connectionString:find('?*$') then
return connectionString:match('[^/][%w]*[?$]'):sub(0, -2)
else
return connectionString:match('[^/][%w]*$')
end
else
connectionString = {string.strsplit(';', connectionString)}
for i=1, #connectionString do