mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
fix(multiplayer): validate ranked season ids
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user