fix(multiplayer): enforce opaque event resource ids

This commit is contained in:
Josh Creek
2026-09-01 22:22:34 +01:00
parent 87d43302e1
commit 17e6a9bc20
3 changed files with 18 additions and 3 deletions
+8 -1
View File
@@ -300,6 +300,13 @@ static func is_valid_rfc3339_timestamp(value: String) -> bool:
return timestamp_pattern.search(value) != null
static func is_valid_resource_id(value: String) -> bool:
if value.length() < 16 or value.length() > 128:
return false
var resource_pattern := RegEx.create_from_string("^[A-Za-z0-9_-]+$")
return resource_pattern.search(value) != null
static func is_retryable_mutation_response(response_code: int) -> bool:
return response_code == 0 or response_code == HTTPClient.RESPONSE_REQUEST_TIMEOUT or response_code == HTTPClient.RESPONSE_TOO_MANY_REQUESTS or response_code >= 500
@@ -474,7 +481,7 @@ static func _valid_websocket_event(event: Dictionary) -> bool:
return false
if not event.has("revision") or not _valid_revision(event["revision"]):
return false
if not event.has("resource_id") or not event["resource_id"] is String or String(event["resource_id"]).is_empty():
if not event.has("resource_id") or not event["resource_id"] is String or not is_valid_resource_id(String(event["resource_id"])):
return false
if not event.has("occurred_at") or not event["occurred_at"] is String or not is_valid_rfc3339_timestamp(String(event["occurred_at"])):
return false