Strip spaces from generated decode report codes
generateSpecialCode() reused generateRandomString(), whose charset includes a space. Across a 75-100 character code that made a space almost certain, and /decode splits its argument on spaces, silently truncating the code the player typed back in - breaking decoding. Fixed at generation time rather than at display time, since the stored value itself was the problem, not just how it's shown. generateRandomString() is left untouched for its other use (the "garbage" filler text shown to players who fail to decode), where spaces are harmless.
This commit is contained in:
@@ -784,7 +784,9 @@ class GameResponseService
|
|||||||
|
|
||||||
private function generateSpecialCode(int $firstDigit, int $min, int $max): string
|
private function generateSpecialCode(int $firstDigit, int $min, int $max): string
|
||||||
{
|
{
|
||||||
$code = $this->generateRandomString($min, $max);
|
// No spaces: this code gets typed back in as a single /decode argument,
|
||||||
|
// which is split on spaces, so a space here would silently truncate it.
|
||||||
|
$code = str_replace(' ', '', $this->generateRandomString($min, $max));
|
||||||
|
|
||||||
// Ensure the first numeric digit is the specified $firstDigit
|
// Ensure the first numeric digit is the specified $firstDigit
|
||||||
$found = false;
|
$found = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user