CCT: no special characters in file names of Coding Contracts

Fixes #4067.  The file name of a Coding Contract follows the format contract-xxx-rewardName.cct.  The part `xxx` means a sequence of random decimal digits.  The part `rewardName` can be an empty string if the player is not part of any faction nor is working for a company.  However, if the player is working for a company or faction whose name has a special character, then the special character would also appear in the generated file name.  We only want alphanumeric characters throughout the whole file name.
This commit is contained in:
Duck McSouls 2022-09-27 00:01:21 +10:00
parent 69eda4340e
commit 819e102fe1

@ -191,7 +191,8 @@ function getRandomFilename(server: BaseServer, reward: ICodingContractReward): s
} }
if (reward.name) { if (reward.name) {
contractFn += `-${reward.name.replace(/\s/g, "")}`; // Only alphanumeric characters in the reward name.
contractFn += `-${reward.name.replace(/[^a-zA-Z0-9]/g, "")}`;
} }
return contractFn; return contractFn;