From e51107503df413c5d9b13d52731b6aa4ef3b76e1 Mon Sep 17 00:00:00 2001 From: Joyless <65855333+Joy-less@users.noreply.github.com> Date: Fri, 2 Jan 2026 02:00:27 +0000 Subject: [PATCH] Fix bugs in C# StringExtensions Co-Authored-By: Raul Santos --- .../GodotSharp/GodotSharp/Core/StringExtensions.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs index b12c82b349..42413eb5d8 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs @@ -926,7 +926,7 @@ namespace Godot return false; int from = 0; - if (instance.Length != 1 && instance[0] == '+' || instance[0] == '-') + if (instance.Length != 1 && (instance[0] == '+' || instance[0] == '-')) { from++; } @@ -935,26 +935,24 @@ namespace Godot { if (instance.Length < 3) return false; - if (instance[from] != '0' || instance[from + 1] != 'x' || instance[from + 1] != 'X') + if (instance[from] != '0' || (instance[from + 1] != 'x' && instance[from + 1] != 'X')) return false; from += 2; } + if (from == instance.Length) + return false; + for (int i = from; i < instance.Length; i++) { char c = instance[i]; - if (IsHexDigit(c)) + if (char.IsAsciiHexDigit(c)) continue; return false; } return true; - - static bool IsHexDigit(char c) - { - return char.IsDigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); - } } ///