From a9198d2a1db9c23910057440216af21f40a05efd Mon Sep 17 00:00:00 2001 From: Luan Santos Date: Wed, 11 Oct 2023 09:52:11 -0700 Subject: [PATCH] fix: bug reports for players with spaces in their name (#1694) --- data/events/scripts/player.lua | 6 ++++-- data/libs/functions/fs.lua | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/data/events/scripts/player.lua b/data/events/scripts/player.lua index 816aa523b70..6ff45d87d65 100644 --- a/data/events/scripts/player.lua +++ b/data/events/scripts/player.lua @@ -398,6 +398,8 @@ function Player:onMoveCreature(creature, fromPosition, toPosition) end local function hasPendingReport(name, targetName, reportType) + name = self:getName():gsub("%s+", "_") + FS.mkdir_p(string.format("%s/reports/players/%s", CORE_DIRECTORY, name)) local file = io.open(string.format("%s/reports/players/%s-%s-%d.txt", CORE_DIRECTORY, name, targetName, reportType), "r") if file then io.close(file) @@ -407,7 +409,7 @@ local function hasPendingReport(name, targetName, reportType) end function Player:onReportRuleViolation(targetName, reportType, reportReason, comment, translation) - local name = self:getName() + name = self:getName() if hasPendingReport(name, targetName, reportType) then self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your report is being processed.") return @@ -444,7 +446,7 @@ function Player:onReportRuleViolation(targetName, reportType, reportReason, comm end function Player:onReportBug(message, position, category) - local name = self:getName() + local name = self:getName():gsub("%s+", "_") FS.mkdir_p(string.format("%s/reports/bugs/%s", CORE_DIRECTORY, name)) local file = io.open(string.format("%s/reports/bugs/%s/report.txt", CORE_DIRECTORY, name), "a") diff --git a/data/libs/functions/fs.lua b/data/libs/functions/fs.lua index f95fba51b05..46e81a7352f 100644 --- a/data/libs/functions/fs.lua +++ b/data/libs/functions/fs.lua @@ -13,7 +13,7 @@ function FS.mkdir(path) if FS.exists(path) then return true end - local success, err = os.execute("mkdir " .. path) + local success, err = os.execute('mkdir "' .. path .. '"') if not success then return false, err end