Is there a way to secure strings for Python's eval?

后端 未结 7 2087
悲哀的现实
悲哀的现实 2021-02-08 07:43

There are many questions on SO about using Python\'s eval on insecure strings (eg.: Security of Python\'s eval() on untrusted strings?, Python: make eval safe).

7条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-08 08:18

    You probably should avoid eval, actually.

    But if your stuck with it, you could just make sure your strings are alphanumeric. That should be safe.

提交回复
热议问题