From f13d910f66dbb38cbf546666807f4eec660ae279 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Mon, 2 Jan 2023 06:13:12 +0100 Subject: [PATCH] Disallow NaN and Infinity in Trivia CONFIG schema (#5949) --- redbot/cogs/trivia/schema.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/redbot/cogs/trivia/schema.py b/redbot/cogs/trivia/schema.py index bc1af8877..0abc7c5fb 100644 --- a/redbot/cogs/trivia/schema.py +++ b/redbot/cogs/trivia/schema.py @@ -1,4 +1,5 @@ import itertools +import math import re from typing import Any, NoReturn @@ -18,8 +19,8 @@ class SchemaErrorMessage(str): def int_or_float(value: Any) -> float: - if not isinstance(value, (float, int)): - raise TypeError("Value needs to be an integer or a float.") + if not isinstance(value, (float, int)) or not math.isfinite(value): + raise TypeError("Value needs to be an integer or a finite float.") return float(value)