fix(multiplayer): validate ranked season ids

This commit is contained in:
Josh Creek
2026-09-01 22:33:54 +01:00
parent ec0bc362cd
commit 3985b74bcf
3 changed files with 18 additions and 3 deletions
+12 -1
View File
@@ -37,7 +37,11 @@ func apply(payload: Dictionary) -> bool:
ranked_games = next_games
tier = next_tier
provisional = bool(payload["provisional"])
season_id = String(payload.get("season_id", ""))
season_id = ""
if payload.has("season_id"):
if not payload["season_id"] is String or not is_valid_opaque_id(String(payload["season_id"])):
return _reject("Profile response contains invalid season identifier")
season_id = String(payload["season_id"])
season_ends_at_unix = 0
if payload.has("season_ends_at"):
if not payload["season_ends_at"] is String or not is_valid_season_timestamp(String(payload["season_ends_at"])):
@@ -58,6 +62,13 @@ static func is_valid_season_timestamp(value: String) -> bool:
return timestamp_pattern.search(value) != null
static func is_valid_opaque_id(value: String) -> bool:
if value.length() < 16 or value.length() > 128:
return false
var id_pattern := RegEx.create_from_string("^[A-Za-z0-9_-]+$")
return id_pattern.search(value) != null
func set_error(reason: String) -> void:
available = false
error_message = reason