fix(safe_eval): Normalize code passed before validating the code
This commit is contained in:
parent
4a81d9f8e3
commit
65a2cdcffc
1 changed files with 2 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ import inspect
|
|||
import json
|
||||
import os
|
||||
import re
|
||||
import unicodedata
|
||||
import warnings
|
||||
from typing import TYPE_CHECKING, Any, Callable, Literal, Optional, TypeAlias, overload
|
||||
|
||||
|
|
@ -2271,6 +2272,7 @@ def bold(text):
|
|||
def safe_eval(code, eval_globals=None, eval_locals=None):
|
||||
"""A safer `eval`"""
|
||||
whitelisted_globals = {"int": int, "float": float, "long": int, "round": round}
|
||||
code = unicodedata.normalize("NFKC", code)
|
||||
|
||||
UNSAFE_ATTRIBUTES = {
|
||||
# Generator Attributes
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue