Skip to content

Commit a087ab0

Browse files
committed
Add validation for parameter conversion in InlineQueryHandler
Previously, parameter conversion in InlineQueryHandler.cs did not check for success, potentially leading to errors. The updated code now verifies the conversion result with a `bool` variable `converted`. Only if `converted` is `true`, it clears and re-adds the arguments to `_args` and returns the method, ensuring the method is only returned if the conversion is successful.
1 parent f160885 commit a087ab0

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Sources/TelegramBot/Handlers/InlineQueryHandler.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,13 @@ public InlineQueryHandler(IReadOnlyCollection<MethodInfo> controllerMethods, Upd
5656
if (match)
5757
{
5858
var args = _args.ToArray();
59-
ObjectHelpers.TryConvertParameters(method, args);
60-
_args.Clear();
61-
_args.AddRange(args);
62-
return method;
59+
bool converted = ObjectHelpers.TryConvertParameters(method, args);
60+
if (converted)
61+
{
62+
_args.Clear();
63+
_args.AddRange(args);
64+
return method;
65+
}
6366
}
6467
}
6568
}

0 commit comments

Comments
 (0)