mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-29 17:27:41 +00:00
Escape *args in render_expression, fix #86
This commit is contained in:
@ -79,7 +79,8 @@ def render_expression(expr: Expression_T, *args,
|
|||||||
elif isinstance(expr, Sequence) and not isinstance(expr, str):
|
elif isinstance(expr, Sequence) and not isinstance(expr, str):
|
||||||
expr = random.choice(expr)
|
expr = random.choice(expr)
|
||||||
if escape_args:
|
if escape_args:
|
||||||
for k, v in kwargs.items():
|
return expr.format(
|
||||||
if isinstance(v, str):
|
*[escape(s) if isinstance(s, str) else s for s in args],
|
||||||
kwargs[k] = escape(v)
|
**{k: escape(v) if isinstance(v, str) else v for k, v in kwargs}
|
||||||
|
)
|
||||||
return expr.format(*args, **kwargs)
|
return expr.format(*args, **kwargs)
|
||||||
|
Reference in New Issue
Block a user